Skip to main content
VESDK/Android/Features

Trim

The Trim tool VideoEditor SDK

The trim tool allows your users to trim the length of the Video.

The frontend is displayed using the TrimToolPanel. If you want to customize the appearance of this tool, take a look at the styling section.

How to enforce a minimum or maximum video length#

To be able to use this feature your subscription must include the trim feature.

As a first step you need to set either setMinimumVideoLength(value:Long, unit:TimeUnit), setMaximumVideoLength(value:Long, unit:TimeUnit), or both on the TrimSettings configuration model. Setting these values when the composition tool is enabled limits the length of the overall composition. Setting these values when the trim tool is enabled limits the length of the video clip.

Composition or trim tool#

The composition tool will only be used if it is included in your subscription and if it is included in the menu items or if both the composition and trim tool are not included as menu items. Otherwise, the trim tool is used if it is included in your subscription.

Force trim modes#

Additionally, you need to specify the forceTrimMode on the TrimSettings model. Possible values are always, ifNeeded, and silent (the default):

  • always will always automatically present the composition tool or the trim tool after opening the editor and force your users to change the length of the video(s).
  • ifNeeded will only present
    • the composition tool, if your initial composition is longer than maximumVideoLength or shorter than minimumVideoLength, or
    • the trim tool, if your initial video is longer than maximumVideoLength.
  • silent will automatically trim the video to the maximumVideoLength without opening any tool.

Behavior and user alerts for exceptions#

If enabled, the trim length will initially be set to the maximumVideoLength. If this value is not set, or the video length is shorter than the maximumVideoLength, it will be set to the full length of the video. The user interface will not allow a trim length that is shorter than minimumVideoLength or longer than maximumVideoLength, 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:

  1. If a minimumVideoLength has 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, the editor is closed.
  2. If a minimumVideoLength has 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. If you do not allow your users to add additional videos to the composition, the behavior will be identical as if the trim tool would have been used above.