VideoEditor SDK supports configuring the
TrimToolController to enforce a minimum and maximum duration of the trimmed video.
For a detailed explanation of how to configure different editor views, refer to this guide.
Min / Max Duration#
By default, no minimum or maximum video durations are enfored.
In cases where you need to restrict the user from shortening the video below a specific minimum duration or importing a video that is too long, you can use the
The unit is seconds, so in this example we only allow videos that are at least two seconds and at most five seconds long.
Behavior and user alerts for exceptions#
If enabled, the trim length will initially be set to the
maximumDuration. If this value is not set, or the video length is shorter than the
maximumDuration, it will be set to the full length of the video. The user interface will not allow a trim length that is shorter than
minimumDuration or longer than
maximumDuration, so users will never be able to generate a video that lies outside these defined limits. However, there are two cases where this behavior can only be achieved with an alert:
- If a
minimumDurationhas been set for the trim tool and the length of the input video is shorter than that, we will present an alert as soon as the editor is opened stating that the video is too short. After confirming that alert,
VideoEditViewControllerDelegate.videoEditViewControllerDidFailToGenerateVideo(_:)will be called which should dismiss the editor. The wording of that alert can be changed using the localization system or the behavior can be completely customized with the
- If a
minimumDurationhas been set for the composition tool and the length of the video composition does not yet overstep that length, tapping on the export button will present an alert that notifies the user that they will have to add additional videos to the composition to export the video. After confirming the alert, the composition tool will automatically open. The wording of that alert can be changed using the localization system or the behavior can be completely customized with the
CompositionToolControllerOptions.compositionTooShortConfirmationClosure. If you do not allow your users to add additional videos to the composition when
CompositionToolControllerOptions.videoClipLibraryModeis set to
none, the behavior will be identical as if the trim tool would have been used above.