VideoEditor SDK supports saving videos to a Base64 encoded string.
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
true, in which case
always point to a newly generated video.
Load Video into Memory#
We create a
Data object from this
url passing it as
contentsOf argument to the constructor.
Note that video file sizes can be large and loading them into memory might not be possible.
Once you are done processing this data, 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.
Convert to Base64 String#
Finally, we convert the
Data object to a Base64 encoded string by invoking
base64EncodedString on it.
This will again increase the amount of memory taken up by the application and the same caveat as above applies.