How to Remove the First Seconds from a Video using FFmpeg

24 October 2022 | 2 min read
Casper Kloppenburg

Prerequisites

FFmpeg is a free and open-source video editing tool capable of trimming, cropping, concatenating, muxing, and transcoding almost any type of media file you throw at it.

It's also a very robust solution for implementing video automation, as we use it extensively in our own video editing API. For this tutorial we'll use FFmpeg 5.1.2, but any recent version will do.

Removing the first seconds

To remove the first seconds of a video, use the following command:

$ ffmpeg -ss 00:05 -i input.mp4 -c:v libx264 -c:a aac output.mp4
  • The -ss 00:05 argument tells FFmpeg to skip the first 5 seconds of the video. Provide a number in seconds or a timestamp in the form of minutes : seconds.
  • -c:v libx264 -c:a aac makes sure that the video is re-encoded as H.256 and AAC.

Removing the first seconds without re-encoding

Unlike the previous example, where the video is completely re-encoded, it is also possible to cut the video without re-encoding by cutting at the nearest I-frame. Whether this works depends on how the video is encoded and where these I-frames are. That's why it doesn't cut exactly where you want it to. It can also cause some video players to have trouble playing the video. So I recommend this only if you can test the video on the players you want to support.

Here's how to cut the first 5 seconds of a video without re-encoding it:

$ ffmpeg -ss 00:05 -i input.mp4 -c:v copy -c:a copy output.mp4

Start automating today

Start with a full-featured trial with 50 credits, no credit card required.
Get started for free