Open AEM120 opened 11 months ago
Some videos work fine, the video example that you have does not produce any issues. While the video example that I provided you have some issues when editing.
Example,
Please watch the following demo:
https://github.com/SilenceLove/HXPhotoPicker/assets/139702862/aee2d12b-c03f-463c-b4de-74e874b46360
ok i will try to fix it
I been using different instruments to see where is the error. But it seems something to do with the EditorVideoCompositor. I also found out that some videos have full cpu usage when processing the edit
I found the problem, this is just a temporary solution
EditorVideoTool.swift
func insertAudioTrack(
duration: CMTime,
timeRang: CMTimeRange,
audioTracks: [AVAssetTrack]
) throws
Modify as follows
var audioInputParams: [AVMutableAudioMixInputParameters] = []
for audioTrack in audioTracks {
guard let track = mixComposition.addMutableTrack(withMediaType: .audio, preferredTrackID: kCMPersistentTrackID_Invalid) else {
continue
}
let audioTimeRange: CMTimeRange = .init(start: .zero, duration: .init(seconds: audioTrack.timeRange.duration.seconds - 0.5, preferredTimescale: audioTrack.timeRange.duration.timescale))
try track.insertTimeRange(audioTimeRange, of: audioTrack, at: .zero)
track.preferredTransform = audioTrack.preferredTransform
let audioInputParam = AVMutableAudioMixInputParameters(track: track)
audioInputParam.setVolumeRamp(fromStartVolume: factor.volume, toEndVolume: factor.volume, timeRange: audioTimeRange)
audioInputParam.trackID = track.trackID
audioInputParams.append(audioInputParam)
}
Video File: https://we.tl/t-pAhUdQeXmG
Open Safari, paste the link and download the video. Go to Files. Save Video to Photos. Using the Demo try to edit the video by cropping "square for example" only Then hit finish "Processing failed"