Alex Balgavy

Just some stuff about me.

Here's my dotfiles repository.

Check out my blog.

My keys: PGP, SSH

My crypto wallets (BTC, XMR)

ffmpeg how to trim x seconds from the end of a video

Written by John Riselvato - original link

Trimming a couple of seconds, minutes or hours off the end of a video is easy but again requires a different understanding of time in FFmpeg. Trimming from the end of an MP4 uses the argument -t or duration with no seeking.

Tip: The duration must be set before the input else FFmpeg applies the duration to the final output.

In this example, the input file is 5 minutes long with the requirement of 1 minute removed from the end:

 $ ffmpeg -t 00:04:00 -i input.mp4 -async 1 output.mp4

By setting a smaller time than the actual video duration, FFmpeg automatically trims the video length (5 minutes – 1 minute = 4 minutes). Now the benefit of manually setting the duration instead of FFmpeg automatically handling it is obvious.