You can trim a video using using so
, eo
and du
options to specify start offset, end offset or duration.
You can also provide an arithmetic expressions like idu_div_2
, bdu_mul_0.2
, or bdu
as a value for these parameter. Doing so will first calculate the value of the expression and then apply transformations using that value. Learn more about arithmetic expressions here.
Start offset - (so)
Specify start offset in seconds. The video before the start offset is removed from the output.
Usage - so-<value>
Possible values - Specify the time in seconds as a positive number up to 2 decimal places, e.g., 20 or 10.55, or an arithmetic expression like idu_div_2
. It must be less than the duration of the input video.
https://ik.imagekit.io/demo/img/60cd.mp4.
https://ik.imagekit.io/demo/img/60cd.mp4?tr=so-5. This will return a video starting from 5th second till the end. The preview below is showing as if video starts at 4th second but that is just one frame, as soon as the video starts playing, it will start from 5th second.
https://ik.imagekit.io/demo/img/60cd.mp4?tr=so-idu_div_2. This will return a video starting from the mid-duration of the original video.
You can also use expressions in the so
parameter inside a layer. To trim the layer video by 80 percent of its original duration, i.e., 56 seconds from starting, you can use the following URL. URL - https://ik.imagekit.io/demo/img/sample-video.mp4?tr=l-video,i-img@@60cd.mp4,w-600,so-idu_mul_0.8,l-end
End offset - (eo)
Specify end offset in seconds. The video after the end offset is removed from the output.
Usage - eo-<value>
Possible values - Specify the time in seconds as a positive number up to 2 decimal places, e.g., 20 or 10.55, or an arithmetic expression like idu_div_2
. It must be less than the duration of the input video.
https://ik.imagekit.io/demo/img/60cd.mp4.
https://ik.imagekit.io/demo/img/60cd.mp4?tr=eo-5. This will return a video starting from the beginning till 5th second.
To trim the video from the end by 20 seconds, you can use the following URL. https://ik.imagekit.io/demo/img/60cd.mp4?tr=eo-idu_sub_20.
You can also use expressions in the eo
parameter inside a layer. To ensure that layer video ends at 50 percent duration of the base video, you can use the following URL. URL - https://ik.imagekit.io/demo/img/sample-video.mp4?tr=l-video,i-img@@60cd.mp4,w-600,eo-bdu_mul_0.5,l-end
Duration - (du)
Specify duration in seconds. It is often used with so
to control the duration of the video to keep in output starting after so
seconds.
Usage - du-<value>
Possible values - Specify the time in seconds as a positive number up to 2 decimal places, e.g., 20 or 10.55, or an arithmetic expression like idu_div_2
. It must be less than or equal to the duration of the input video.
https://ik.imagekit.io/demo/img/60cd.mp4.
https://ik.imagekit.io/demo/img/60cd.mp4?tr=so-5,du-5. This will return a video starting from 5th second and will be 5 seconds long.
To trim the video 10 percent from starting, and play it for next 40% you can use the following URL. https://ik.imagekit.io/demo/img/60cd.mp4?tr=so-idu_mul_0.1,du-idu_mul_0.4.
You can also use expressions in the du
parameter inside a layer. To ensure that layer video plays for 70 percent duration of the base video, you can use the following URL. URL - https://ik.imagekit.io/demo/img/sample-video.mp4?tr=l-video,i-img@@60cd.mp4,w-600,du-bdu_mul_0.7,l-end