Skip to content

Commit

Permalink
Fix wrong durations for uploaded media
Browse files Browse the repository at this point in the history
At some point Uniffi introduced [automatic conversions](https://github.com/mozilla/uniffi-rs/blob/35140607dce7092f04d619a5d0b07f9ffe98b4ff/uniffi_bindgen/src/bindings/swift/templates/DurationHelper.swift#L19) from Rust's `Duration` to `TimeInterval`s but the original implementation for media uploading was using milliseconds. When the conversion happened there were no breaking changes and iOS kept sending millis instead of seconds, resulting in **very** wrong values.
  • Loading branch information
stefanceriu committed Sep 10, 2024
1 parent 1a3378f commit 958273d
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ private struct VideoProcessingInfo {
let url: URL
let height: Double
let width: Double
let duration: Double
let duration: Double // seconds
let mimeType: String
}

Expand Down Expand Up @@ -213,7 +213,7 @@ struct MediaUploadingPreprocessor {
return .failure(.failedProcessingAudio)
}

let audioInfo = AudioInfo(duration: durationInSeconds * 1000, size: fileSize, mimetype: mimeType)
let audioInfo = AudioInfo(duration: durationInSeconds, size: fileSize, mimetype: mimeType)
return .success(.audio(audioURL: url, audioInfo: audioInfo))
}

Expand Down Expand Up @@ -413,7 +413,7 @@ struct MediaUploadingPreprocessor {
return .success(.init(url: newOutputURL,
height: adjustedNaturalSize.height,
width: adjustedNaturalSize.width,
duration: durationInSeconds * 1000,
duration: durationInSeconds,
mimeType: "video/mp4"))
} catch {
return .failure(.failedConvertingVideo)
Expand Down

0 comments on commit 958273d

Please sign in to comment.