Skip to main content
VESDK/iOS/Guides/Save & Restore Editor State


VideoEditor SDK for iOS supports serialization and deserialization, allowing your users to save and revise their work at any time.

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.

In order to obtain a Data object of all edits that have been applied to the exported video, simply call serializedSettings on the videoEditViewController. You can optionally convert these settings to a JSON string or JSON dictionary. For details on the JSON structure you can download our schema.

For further processing you can save the data to the local file system (compare Save Video to File System) or upload it to a remote server (compare Save Video To Remote Server) to make the editor state available on other devices as well.

The next section explains how to restore the editor state by deserializing these settings.

import UIKit
import VideoEditorSDK
class VideoSerializationSwift: Example, VideoEditViewControllerDelegate {
override func invokeExample() {
// Create a `Video` from a URL to a video in the app bundle.
let video = Video(url: Bundle.main.url(forResource: "Skater", withExtension: "mp4")!)
// Create and present the video editor. Make this class the delegate of it to handle export and cancelation.
let videoEditViewController = VideoEditViewController(videoAsset: video)
videoEditViewController.delegate = self
videoEditViewController.modalPresentationStyle = .fullScreen
presentingViewController?.present(videoEditViewController, animated: true, completion: nil)
// MARK: - VideoEditViewControllerDelegate
func videoEditViewControllerShouldStart(_ videoEditViewController: VideoEditViewController, task: VideoEditorTask) -> Bool {
// Implementing this method is optional. You can perform additional validation and interrupt the process by returning `false`.
func videoEditViewControllerDidFinish(_ videoEditViewController: VideoEditViewController, result: VideoEditorResult) {
// The user exported a new video successfully and the newly generated video is located at `result.output.url`.
// To get a `Data` object of all edits which have been applied to a video, you can use the following method.
let serializedSettings = videoEditViewController.serializedSettings
// Optionally, you can convert the serialized settings to a JSON string if needed.
let jsonString = String(data: serializedSettings!, encoding: .utf8)
// Or to a `Dictionary`.
let jsonDict = try? JSONSerialization.jsonObject(with: serializedSettings!, options: [])
print(jsonDict! as Any)
// You can use either `serializedSettings`, `jsonString`, or `jsonDict` for further processing, such as
// uploading it to a remote URL or saving it to the filesystem. See `SaveVideoToRemoteURLSwift` or
// `SaveVideoToFilesystemSwift` to get an idea about the approach to take for this.
// For loading serialized settings into the editor, please take a look at `VideoDeserializationSwift`.
// Dismiss the editor.
presentingViewController?.dismiss(animated: true, completion: nil)
func videoEditViewControllerDidFail(_ videoEditViewController: VideoEditViewController, error: VideoEditorError) {
// There was an error generating the video.
// Dismissing the editor.
presentingViewController?.dismiss(animated: true, completion: nil)
func videoEditViewControllerDidCancel(_ videoEditViewController: VideoEditViewController) {
// The user tapped on the cancel button within the editor. Dismissing the editor.
presentingViewController?.dismiss(animated: true, completion: nil)