Aral Balkan

Mastodon icon RSS feed icon

How to trim an MP4 video without re-encoding it

You have an MP4 file and all you need to do is trim a few seconds off from either the start or the end (or both). And you don’t want to spend time cutting it in a non-linear editor and re-exporting it and waiting for it to encode again.

If you do not need frame-level precision1, there is a near-instant way you can do it using ffmpeg2.

For example, I trimmed the last few seconds off my previous video – which I’d saved as obs-demo.mp4 ­– using the following command to take everything from the very beginning until the 2 minute 13 second mark and to create a new file called obs-demo-trimmed.mp4 with it:

ffmpeg -ss 00:00:00 -i obs-demo.mp4 -to 00:02:13 -c copy obs-demo-trimmed.mp4

Hope this saves you some time.

Source


  1. This technique has keyframe-level precision. ↩︎

  2. If you don’t have it, you can install it on Debian-esque systems with:

    sudo apt install ffmpeg
    ↩︎