How to Set Loop Start Frame in FFmpeg Loop Filter

This article explains how to configure the loop start frame using the FFmpeg loop video filter. You will learn the exact parameter syntax required to define the starting frame of a loop, how to calculate the frame index from a timestamp, and see practical command-line examples.

To configure the loop start frame in FFmpeg, you must use the loop video filter (-vf loop) and define its three primary parameters: loop, size, and start.

The starting frame is controlled specifically by the start parameter, which uses a 0-based frame index.

The Loop Filter Syntax

The basic syntax for the filter is:

loop=loop=<count>:size=<frames>:start=<frame_index>

Practical Example

If you have a 30 fps video and want to loop a 3-second segment (90 frames) starting at the 5-second mark, you first need to calculate the start frame: * Start Frame = 5 seconds * 30 fps = 150

To loop this 90-frame segment 5 times, use the following command:

ffmpeg -i input.mp4 -vf "loop=loop=5:size=90:start=150" -c:a copy output.mp4

Key Considerations

  1. Audio Sync: The loop video filter only loops the video stream. If your input has audio, the audio will continue to play normally while the video loops. To keep them in sync, you may need to loop the audio separately using the aloop filter.
  2. Frame Rate: Always verify the frame rate of your input video to accurately calculate the start frame index from a specific time in seconds.