Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Processing failed on some videos #560

Open
AEM120 opened this issue Jul 16, 2023 · 4 comments
Open

Processing failed on some videos #560

AEM120 opened this issue Jul 16, 2023 · 4 comments

Comments

@AEM120
Copy link

AEM120 commented Jul 16, 2023

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"

simulator_screenshot_31B7FF9B-AE61-4DBB-B61B-F3B11C81D0B4

@AEM120
Copy link
Author

AEM120 commented Jul 16, 2023

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,

  1. select the video, and crop it to square. click finish, you get processing failed.
  2. select the video, and trim from the start. click finish, you get processing failed.

Please watch the following demo:

Demo.mp4

@SilenceLove
Copy link
Owner

ok i will try to fix it

@AEM120
Copy link
Author

AEM120 commented Jul 17, 2023

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
Screenshot 2023-07-17 at 6 43 01 AM
Screenshot 2023-07-17 at 6 43 21 AM

@SilenceLove
Copy link
Owner

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)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants