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.

What Does "Skipping Frames" Mean?

When you skip frames with FFmpeg, you’re telling the encoder or filter to ignore certain frames from the input video. This could mean:

  • Ignoring the first few frames.
  • Skipping frames at a regular interval (e.g., dropping every other frame).
  • Skipping specific types of frames (e.g., skipping all B-frames).
  • Seeking to a specific timestamp to start processing from there.

Skipping frames is not just about trimming footage; it’s about controlling how frames are read, processed, or transcoded—ultimately saving time and resources.

Why Skip Frames in FFmpeg?

  1. Performance: Shorter processing times if you don’t need specific frames.
  2. File Size Reduction: Smaller output files if fewer frames are encoded.

Methods for Skipping Frames

Using the -ss Flag

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.

Using the select Filter

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.

Using -skip_frame

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:

  1. nokey: Most aggressive – Decodes only key (I) frames, skipping all others. Good for quickly grabbing thumbnails, but the video will look very choppy.
  2. noref: Moderately aggressive – Skips frames not used for reference, so it decodes I-frames and only the necessary P-frames. Saves CPU power and gives a smoother video than nokey.
  3. bidir: Least aggressive – Skips only bidirectional (B) frames, decoding both I-frames and P-frames. Offers smoother playback with only a slight decrease in processing load.
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.

Skipping Frames at a Fixed Interval

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.

Best Practices & Pitfalls

  1. Audio & Video Sync: When skipping frames, your audio track might go out of sync. Consider copying audio (-c:a copy) or applying audio filters to keep them aligned.
  2. Variable Frame Rate: If your source has a variable frame rate, using -ss or skipping by time may be more reliable than skipping by frame indices (n).
  3. Re-Encoding vs. Copy: Using -c copy can be fast but limits your frame manipulations; re-encoding (-c:v libx264, etc.) offers more flexibility.
  4. Performance: For heavy operations, test different configurations (like re-encoding vs. copying, or placing -ss before vs. after -i). Performance can vary widely based on your environment.

Get started with Shotstack's video editing API in two steps:

  1. Sign up for free to get your API key.
  2. Send an API request to create your video:
    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
    }
    }
    }'
Derk Zomer

BY DERK ZOMER
19th February 2025

Studio Real Estate
Experience Shotstack for yourself.
SIGN UP FOR FREE

You might also like

Use FFmpeg to crop videos

Use FFmpeg to crop videos

Kathy Calilao
 Convert videos to MP3 using FFmpeg

Convert videos to MP3 using FFmpeg

Jeff Shillitto
How to trim a video using FFmpeg

How to trim a video using FFmpeg

Joyce Echessa