91.22 Video Trim and Cut
20230802
This section deals with the extraction of time extents of the video, that is, to trim or to cut the video. If you are wanting to crop the video image itself throughout a video see Section 91.11. If you want the cut a section out of a video, then cut the video into two sections, pre and post the part to be cut, and concat the two parts together as explained in Section 91.4.
Using ffmpeg we can extract a segment from a video
file input.mp4
(identified as the input using -i
) starting at the
location 7 minutes and 41 seconds from the beginning using -ss
and
ending at the 53 minute mark from the beginning of the video using
-to
. The audio stream will be synchronised at the beginning of the
output stream to match the timestamp using -async 1
. To avoid
re-encoding of the video use the -c copy
command to ensure that the
video is simply copied.
If the -c copy
is not present then the process will undertake a
re-encoding of the video and can take some time.
By replacing -to
with -t
the output will be truncated after the
specified duration.
If -t
is specified prior to -i
(the input) then the duration
refers to the input video rather than the output video. That is, it
specifies the duration from the beginning of the input video.
Using avisplit we can also extract a particular section
of an avi file (specified as the -i
nput file) and using -t
to
specifiy the starting point and the end point (starting at 7 minutes
and 20 seconds into the video and stopping at 8 minutes and 20 seconds
in, respectively):
Other Options
A graphical interface to trim a video is Video Trimmer which is installable as a FlatPack.
Your donation will support ongoing availability and give you access to the PDF version of this book. Desktop Survival Guides include Data Science, GNU/Linux, and MLHub. Books available on Amazon include Data Mining with Rattle and Essentials of Data Science. Popular open source software includes rattle, wajig, and mlhub. Hosted by Togaware, a pioneer of free and open source software since 1984. Copyright © 1995-2022 Graham.Williams@togaware.com Creative Commons Attribution-ShareAlike 4.0