Cut videos using FFMPEG

In this post we are going to show you how to cut any video using ffmpeg tool.

Ffmpeg cut command

ffmpeg -i input_video.mp4 -ss 00:00:05.0000 -t 3 output_video.mp4

This is what you need:

  • -ss is used as the start timestamp. If you want to cut the video from the second 5, you can put like in the example (using hours:minutes:seconds:microseconds), or you can put 5 directly (if you do not specify timestamp ffmpeg will understand the parameter as seconds)

  • -t specifies the duration of the video being cut. In this example with 3 we are telling ffmpeg to cut 3 seconds of the original video

  • output_video.mp4 is the output video name. As in other cases we can use another format so ffmpeg will encode the resulting video in another format.

You can also use the parameter -to instead of using the -t parameter. In this case, the -to parameter specifies the final timestamp of the section being cut and not the duration of the video. For the prior case if we want to cut from second 5 to second 8 of the video we use:

ffmpeg -i input_video.mp4 -ss 5 -to 8 output_video.mp4

As these methods encode the result you should be wary of the encoding parameters. We have not included any, using the defaults, but if the input video has very high quality and you also want high quality result you should be including some encoding parameters to override defaults. Check out our articles on ffmpeg mp4 encoding, ffmpeg mkv encoding or ffmpeg webm encoding for more information depending on which format you want to use in the output file.

The copy issue

You can find in the documentation or in other sites the recommendation to use -c copy parameter (or use -vcodec copy and -acodec copy for audio) which makes ffmpeg to copy the stream instead of process and encode it. I have found that depending on the input file format and its encoding you can experience slowdowns on the video or even blank screens during the initial part of the video (or during the full video depending on the duration of the extracted video). However, you can try with this command:

ffmpeg -i input_video.mp4 -ss 5 -t 3 -c copy output_video.mp4

This method has the advantage that no encoding process is done, so the cut process is a lot faster. Also you mantain original quality so you don't have to worry about encoding parameters.

As this method is a lot faster you can try first this method, and if you don't like the result you can try the other one with encoding process.

    Did you find this article helpful?