SilenceLove / HXPHPicker

Photo/Video Selector-Supports LivePhoto, GIF selection, online download of resources on iCloud, and editing of photos/videos
MIT License
364 stars 74 forks source link

Video Editor issue #90

Closed t3b123 closed 2 years ago

t3b123 commented 2 years ago
Screenshot 2022-11-03 at 2 07 13 PM

Sometime when a user select a video and they want to export the video they will get a video like the one above.

SilenceLove commented 2 years ago

Can you send me the original video?

t3b123 commented 2 years ago

I don't have the video because this is from a user. However, it to do with editing a video. Once you edit the video and you are trying to export it. it creates this type of issue. I think its the way how the video being exported creates this issue.

SilenceLove commented 2 years ago

Is there a way to reproduce this issue?

t3b123 commented 2 years ago

one of the user said he saved the video from tiktok. so i think its the way the video being formatted. just a note, when I was talking to the user he said the preview its fine even if he edit the video. but as soon as he hit "Finish" it will say processing failed. or some users will get half screen video like the one above

t3b123 commented 2 years ago

So the problem occurs on the file called VideoEditorViewController+ToolView.swift it seems like the error happens here // if videoURL != nil { // ProgressHUD.hide(forView: self?.view, animated: true) // self?.editFinishCallBack(urlConfig) // self?.backAction() // }else { // self?.showErrorHUD() THIS IS what makes the processing fails // }

t3b123 commented 2 years ago

Maybe its to do with the url or the way you export the video is wrong

SilenceLove commented 2 years ago

The location of the problem is found, the next version will fix this problem

SilenceLove commented 2 years ago

You can modify the code in this place of the source code to solve this problem first Line 71 of CustomVideoCompositionInstruction.swift

guard let instruction = request.videoCompositionInstruction as? CustomVideoCompositionInstruction,
           let trackID = instruction.requiredSourceTrackIDs?.first as? CMPersistentTrackID,
           let pixelBuffer = request.sourceFrame(byTrackID: trackID) else {
    return nil
}

change into

guard let instruction = request.videoCompositionInstruction as? CustomVideoCompositionInstruction,
           let trackID = instruction.requiredSourceTrackIDs?.first as? CMPersistentTrackID else {
    return nil
}
guard let pixelBuffer = request.sourceFrame(byTrackID: trackID) else {
    return renderContext?.newPixelBuffer()
}