How to trim video using FFmpeg?

How to trim a video into multiple parts in FFmpeg?

With FFmpeg, we can trim multiple parts of a video in a single command by specifying the start time and duration of each segment using a number of -ss and -t options. These segments will concatenate using the concat filter in FFmpeg.

In the example given below, we will cut the video into three parts:

ffmpeg -i input.mp4 \

-ss 00:00:00 -t 00:00:10 -c:v copy -c:a copy part1.mp4 \

-ss 00:00:10 -t 00:00:20 -c:v copy -c:a copy part2.mp4 \

-ss 00:00:20 -c:v copy -c:a copy part3.mp4

ffmpeg -i "concat:part1.mp4|part2.mp4|part3.mp4" -c copy output.mp4

In above,

  • input.mp4 is the input video file and part1, part2, part3 are the output files.
  • Here, we are using the multiple -ss and -t options to set the start time and duration of each part, and the resulting parts are saved as part1.mp4, part2.mp4, and part3.mp4.
  • In the second line, we are using the concat filter provided by FFmpeg to concatenate the three parts into a single output file named output.mp4.
  • The -c copy option tells the FFmpeg to copy the video and audio streams without re-encoding, preserving the original quality of the video.

Here is how a single video can be divided into several portions.

However, follow these instructions to trim and preserve metadata.