Cutting video with
You can accurately cut videos with FFmpeg. Since version 2.5 it's very easy.
This would for example cut 10 seconds, starting from 0 minutes, 3 seconds and 123 milliseconds.
ffmpeg -ss -ss 00:00:03.123 -i input.mp4 -t 10 -c:v libx264 -c:a aac -strict experimental out.mp4
The position and the time may be either in seconds or in
Note that in these examples, video and audio will be re-encoded using the x264 and aac encoders.
You can also use
-to instead of
-t to specify the end point instead of the duration. In this case, however,
-to is equivalent to
-t, since by putting the
-ss in front of
-i, ffmpeg will first seek to that point and then start outputting.
See also the Seeking wiki entry.
Accurate cutting for older
If you have an older version of ffmpeg, then for accurate seeking, you need to place the
-i, which makes the encoding process a little slower, because the entire video has to be decoded first:
ffmpeg -i input.mp4 -ss 00:00:03.123 -t 10 -c:v libx264 -c:a aac -strict experimental out.mp4
-t behave differently.
-t 10 would create a ten second long clip, whereas
-to 10 would create a clip that is seven seconds long.
Stream copying vs. re-encoding
You can try copying over the audio stream with
-c:a copy too. Copying the video stream can be done with
-c:v copy. It may however not work properly because you can only cut a video keyframes, which don't occur so often. In any case, it might lead to inaccurate cutting if you copy the video stream.