Skip to main content
Language

To a Remote URL

VideoEditor SDK supports saving videos to a remote URL.

For the sake of this example, we create a video from a URL and present the video editor in a modal. Note, that we have to make the current class the delegate of the VideoEditViewController in order to handle export and cancellation there.

Implementing the Video Export Delegate Method#

When a video export is successful the method videoEditViewControllerDidFinish is invoked on the delegate class and a VideoEditorResult object is passed as an argument.

If no modifications have been made to the original video, we will not process the original video at all and also not reencode it. In this case, result.output.url will point to the original video that was passed to the editor, if available.

If you want to ensure that the original video is always reencoded, even if no modifications have been made to it, you can set VideoEditViewControllerOptions.forceExport to true, in which case result.output.url will always point to a newly generated video.

Create a Request Object#

In order to upload the exported video, create a URLRequest object for the web service that is supposed to receive the video upload and set the httpMethod to POST.

Create an Upload Task#

Using the URLSession networking API we create an uploadTask passing the url, urlRequest and a closure to handle the request outcome. In this example, we simply log the status code and potential errors. In a production app you would display some message to the user communicating the status of the request.

Once the upload successfully finished, we recommend that you delete the temporary file. Here, we first check whether the video file was passed without changes. This check is only necessary when working with the Simulator, since in production the app bundle is read-only.

Start Upload Task in Background#

Invoking the method resume on the upload tasks starts it in the background, allowing us to dismiss the view controller immediately.