How to Use the -accurate_seek Option in FFmpeg

This article explains how to use the -accurate_seek option in FFmpeg to achieve precise video trimming and seeking. You will learn how this option works, why it is essential for cutting videos at exact timestamps, and how to write the correct command-line syntax to control seeking behavior during video editing.

Understanding -accurate_seek

By default, FFmpeg enables the -accurate_seek option when you use the -ss (seek) parameter. When seeking through a video, FFmpeg jumps to the nearest keyframe before your target timestamp and then decodes the remaining frames in the background until it reaches the exact millisecond you requested. This process ensures that your output video begins at the precise frame you specified.

If you disable this option, FFmpeg will simply start the output at the nearest keyframe, which can result in several seconds of unwanted footage at the beginning of your cut.

How to Enable -accurate_seek

Since -accurate_seek is enabled by default in modern versions of FFmpeg, you typically do not need to add it explicitly when re-encoding. However, if you want to ensure it is forced, you must place the -accurate_seek flag after the input file (-i) and before the output file name.

Here is the standard command for an accurate seek with video re-encoding:

ffmpeg -ss 00:01:30 -i input.mp4 -accurate_seek -to 00:02:00 -c:v libx264 -c:a aac output.mp4

In this command: * -ss 00:01:30 tells FFmpeg to seek to the 1 minute and 30 second mark. * -accurate_seek ensures the cut starts precisely at that timestamp. * -to 00:02:00 stops the output at the 2-minute mark. * -c:v libx264 re-encodes the video, which is required for frame-accurate cuts.

The Limitation with Stream Copying (-c copy)

A common mistake is trying to use -accurate_seek while copying video streams without re-encoding (using -c copy or -codec copy).

# This will NOT be frame-accurate
ffmpeg -ss 00:01:30 -i input.mp4 -accurate_seek -to 00:02:00 -c copy output.mp4

Because stream copying does not re-encode the video, FFmpeg cannot create a new keyframe at your designated start time. It is forced to start the video at the nearest actual keyframe prior to 00:01:30. If you require absolute frame accuracy, you must re-encode the video instead of using stream copying.

How to Disable Accurate Seeking

If you are dealing with very large files and speed is your main priority, you can disable accurate seeking. This is useful when you do not care about frame-level precision and want to skip the background decoding process.

To disable it, use the -noaccurate_seek flag:

ffmpeg -ss 00:45:00 -i input.mp4 -noaccurate_seek -to 00:50:00 -c:v libx264 -c:a aac output.mp4

By adding -noaccurate_seek, FFmpeg will immediately jump to the nearest keyframe and begin processing, saving CPU cycles and time, though the start point of your output video will be slightly off.