Getting "Video export failed" ERROR when I try to trim a video with UIVideoEditorController

My CODE:

the mediaURL.path is obtained from UIImagePickerControllerDelegate

guard UIVideoEditorController.canEditVideo(atPath: mediaURL.path) else { return }

let editor = UIVideoEditorController()

editor.delegate = self

editor.videoPath = mediaURL.path

editor.videoMaximumDuration = 10

editor.videoQuality = .typeMedium

self.parentViewController.present(editor, animated: true)

Error description on console as below.

Video export failed for asset <AVURLAsset: 0x283c71940, URL = file:///private/var/mobile/Containers/Data/PluginKitPlugin/7F7889C8-20DB-4429-9A67-3304C39A0725/tmp/trim.EECE5B69-0EF5-470C-B371-141CE1008F00.MOV>: Error Domain=AVFoundationErrorDomain Code=-11800

It doesn't call

func videoEditorController(_ editor: UIVideoEditorController, didFailWithError error: Error)

After showing error on console, UIVideoEditorController automatically dismiss itself.

Am I doing something wrong? or is it a bug in swift?

Thank you in advance.

Answered by tenna in 689235022

I solved this. I was trying to edit my video directly from photolibary.

So, save the video to documentDirectory first, then edit worked for me.

Accepted Answer

I solved this. I was trying to edit my video directly from photolibary.

So, save the video to documentDirectory first, then edit worked for me.

Getting "Video export failed" ERROR when I try to trim a video with UIVideoEditorController
 
 
Q