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 90.9. 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 90.2.
Using ffmpeg we can extract a segment from a video
input.mp4 (identified as the input using
-i) starting at the
location 7 minutes and 41 seconds from the beginning using
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.
$ ffmpeg -i input.mp4 -ss 00:07:41 -to 00:53:00 -async 1 -c copy cut.mp4
-c copy is not present then the process will undertake a
re-encoding of the video and can take some time.
$ ffmpeg -i input.mp4 -ss 00:07:41 -to 00:53:00 cut.mp4
-t the output will be truncated after the
$ ffmpeg -i input.mp4 -ss 00:07:41 -t 00:45:19 -async 1 -c copy cut.mp4
-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
-input file) and using
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
$ avisplit -i a.avi -t 0:7:20.0-0:8:20.0
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