GNU/Linux Desktop Survival Guide
by Graham Williams |
|||||
Video Trim and Cut |
20201113 This section deals with the extraction of time extents of the video, that is, trim or cut the video. If you are wanting to crop the video image itself throughout a video see Section 89.6.
Using ffmpeg we can extract a segment
from a video (-i
identifies the input file) from the
beginning (-ss
says to discard anything before the provided
timestamp) of the video to 11 seconds in (-t
will stop
writing to the output file after the specified duration of the output
video) whilst the audio stream is synchronised at the beginning of the
output stream to match the timestamp (using -async
1). The following command produces a video of length 11
seconds.
$ ffmpeg -i input.mp4 -ss 00:00:00 -t 00:00:11 -async 1 cut.mp4 |
Note that if -t
is specified prior to -i
(the
input) then the duration refers to the input video rather than the
output video. For the above example it would make no difference since
we are not cropping the beginnig of the 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):
$ avisplit -i a.avi -t 0:7:20.0-0:8:20.0 |
Other Options
A graphical interface to trim a video is Video Trimmer which is installable as a FlatPack.