mirror of
https://github.com/samsonjs/SJSAssetExportSession.git
synced 2026-04-27 14:57:46 +00:00
Remove SampleWriter.duration
This commit is contained in:
parent
d995fbab46
commit
d82bd64635
1 changed files with 8 additions and 10 deletions
|
|
@ -37,7 +37,6 @@ actor SampleWriter {
|
||||||
private let audioMix: AVAudioMix?
|
private let audioMix: AVAudioMix?
|
||||||
private let videoOutputSettings: [String: any Sendable]
|
private let videoOutputSettings: [String: any Sendable]
|
||||||
private let videoComposition: AVVideoComposition?
|
private let videoComposition: AVVideoComposition?
|
||||||
private let duration: CMTime
|
|
||||||
private let timeRange: CMTimeRange
|
private let timeRange: CMTimeRange
|
||||||
|
|
||||||
// MARK: Internal state
|
// MARK: Internal state
|
||||||
|
|
@ -66,11 +65,6 @@ actor SampleWriter {
|
||||||
|
|
||||||
(progressStream, progressContinuation) = AsyncStream<Float>.makeStream()
|
(progressStream, progressContinuation) = AsyncStream<Float>.makeStream()
|
||||||
|
|
||||||
let duration = if let timeRange {
|
|
||||||
timeRange.duration
|
|
||||||
} else {
|
|
||||||
try await asset.load(.duration)
|
|
||||||
}
|
|
||||||
let reader = try AVAssetReader(asset: asset)
|
let reader = try AVAssetReader(asset: asset)
|
||||||
if let timeRange {
|
if let timeRange {
|
||||||
reader.timeRange = timeRange
|
reader.timeRange = timeRange
|
||||||
|
|
@ -102,8 +96,11 @@ actor SampleWriter {
|
||||||
self.videoComposition = videoComposition
|
self.videoComposition = videoComposition
|
||||||
self.reader = reader
|
self.reader = reader
|
||||||
self.writer = writer
|
self.writer = writer
|
||||||
self.duration = duration
|
self.timeRange = if let timeRange {
|
||||||
self.timeRange = timeRange ?? CMTimeRange(start: .zero, duration: duration)
|
timeRange
|
||||||
|
} else {
|
||||||
|
try await CMTimeRange(start: .zero, duration: asset.load(.duration))
|
||||||
|
}
|
||||||
|
|
||||||
try await setUpAudio(audioTracks: audioTracks)
|
try await setUpAudio(audioTracks: audioTracks)
|
||||||
try await setUpVideo(videoTracks: videoTracks)
|
try await setUpVideo(videoTracks: videoTracks)
|
||||||
|
|
@ -287,8 +284,9 @@ actor SampleWriter {
|
||||||
|
|
||||||
// Only yield progress values for video. Audio is insignificant in comparison.
|
// Only yield progress values for video. Audio is insignificant in comparison.
|
||||||
if output == videoOutput {
|
if output == videoOutput {
|
||||||
let samplePresentationTime = CMSampleBufferGetPresentationTimeStamp(sampleBuffer) - timeRange.start
|
let endTime = CMSampleBufferGetPresentationTimeStamp(sampleBuffer)
|
||||||
let progress = Float(samplePresentationTime.seconds / duration.seconds)
|
let samplePresentationTime = endTime - timeRange.start
|
||||||
|
let progress = Float(samplePresentationTime.seconds / timeRange.duration.seconds)
|
||||||
progressContinuation.yield(progress)
|
progressContinuation.yield(progress)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue