Skipping frames in FFmpeg can significantly speed up your video processing, reduce output size, and optimize your workflow. This guide covers everything you need to know about frame skipping—from fundamental commands for beginners to advanced filters that give power users full control.
When you skip frames with FFmpeg, you’re telling the encoder or filter to ignore certain frames from the input video. This could mean:
Skipping frames is not just about trimming footage; it’s about controlling how frames are read, processed, or transcoded—ultimately saving time and resources.
The -ss flag in FFmpeg allows you to seek to a specific time before processing. This essentially “skips” frames up to that point.
ffmpeg -ss 5 -i input.mp4 -c copy output.mp4
-ss 5
: Skips the first 5 seconds of the input file.-i input.mp4
: Input file.-c copy
: Copies audio and video codecs without re-encoding.Note: Placing -ss
before -i
provides a faster, more precise seek in most cases.
FFmpeg’s select
filter is an advanced way to conditionally include or exclude frames based on specific criteria. For example, you can skip every other frame or skip frames based on timestamps.
ffmpeg -i input.mp4 \
-vf "select='not(mod(n,2))',setpts=N*2/FRAME_RATE/TB" \
-c:v libx264 -preset fast -c:a copy \
output.mp4
select=‘not(mod(n,2))’
: Keeps only frames where n (the frame index) is even, effectively dropping every other frame.setpts=N*2/FRAME_RATE/TB
: Adjusts the presentation timestamp so that playback speed remains correct after dropping frames.-c:v libx264
: Encodes video using H.264.-preset fast
: Faster encoding preset.-c:a copy
: Copies audio stream without changes.This turns a 60fps video into a 30fps video.
Using select
is powerful for advanced scenarios where you want precise control over which frames get dropped based on frame index, time, or other conditions.
FFmpeg’s -skip_frame
parameter allows you to skip certain frame types (e.g., B-frames). This is useful when wanting to optimise video processing and gives you a few different options:
ffmpeg -skip_frame noref -i input.mp4 -c:v libx264 -c:a copy output.mp4
-skip_frame noref
: Skips all frames that are not keyframes.-i input.mp4
: Input file.-c:v libx264
: Encodes video using H.264.-c:a copy
: Copies audio stream without changes.Dropping frames at a known interval is useful for creating stop-motion effects or reducing file size while maintaining partial continuity.
ffmpeg -i input.mp4 \
-vf "select='not(mod(n,18))',setpts=N*18/FRAME_RATE/TB" \
-c:v libx264 -c:a copy \
output.mp4
'not(mod(n,18))'
: Keeps only frames where n % 18 == 0
, dropping the rest.curl --request POST 'https://api.shotstack.io/v1/render' \
--header 'x-api-key: YOUR_API_KEY' \
--data-raw '{
"timeline": {
"tracks": [
{
"clips": [
{
"asset": {
"type": "video",
"src": "https://shotstack-assets.s3.amazonaws.com/footage/beach-overhead.mp4"
},
"start": 0,
"length": "auto"
}
]
}
]
},
"output": {
"format": "mp4",
"size": {
"width": 1280,
"height": 720
}
}
}'