How to Trim Video Using FFmpeg – Lossless Trimming

Sometimes we need to cut/trim video files. In this article, we will discuss two easy and fastest methods to trim video files using FFmpeg. This method will keep the quality of the original video file, most of the graphical video editing software may recompress the video file on export which can cause loss of video quality. The below methods uses “lossless” video trimming.

  1. Using FFmpeg command tool
  2. Using ExMplayer media cutter tool

Trim video file using FFmpeg

FFmpeg is a free open source tool to record, convert and stream audio and video. The first step is to install FFmpeg.

Install FFmpeg for Windows users

Download FFmpeg binaries for windows from FFmpeg official site here . Extract files and run FFmpeg command-line tool in the bin folder.

Install FFmpeg for Linux users

For Ubuntu users, run the following command to install FFmpeg.

sudo apt install ffmpeg

Open the terminal and type “ffmpeg” to verify the installation.

Cut the video file using the following one-line command

ffmpeg -i input_video.mp4 -ss 01:30:15 -to 02:30:15 -c:v copy -c:a copy output_video.mp4

The above command will cut out a section from the video file from about 1h30min(after -ss option) to 2h30 min(after -to option) and the copy option tells FFmpeg to trim without recompressing media, it will take few seconds to complete the operation. Explanation of each option

  • i – means input (path of the input file)
  • ss – Start position time
  • to – End position time
  • c:v copy – Copy video codec
  • c: a copy – Copy audio codec

Trim video file using ExMplayer

ExMplayer is a free cross-platform media player. It has a media cutter tool it can be used to cut/trim video files without losing quality. ExMplayer video trimming is based on FFmpeg lossless trimming.

First, step download and install ExMplayer from the official site.

Follow the steps to cut the video file

Open and play video file and open media cutter tool (Menu -> Tools -> Media cutter)

ffmpeg media cutter

Mark start position by pressing the “mark start” button

media cutter mark start

Mark stop position by pressing the “mark stop” button and cut the video by pressing the cut button.

media cutter mark stop

Conclusion

There you have it, two simple FFmpeg-based methods to cut video files without losing the video quality. Hope you enjoyed reading article.

1 thought on “How to Trim Video Using FFmpeg – Lossless Trimming”

Leave a Comment