FFmpeg Select Filter: How to Extract P-Frames

This guide provides a straightforward tutorial on how to use the FFmpeg select video filter to isolate and extract P-frames (predictive frames) from a video file. You will learn the exact command-line syntax required to filter these specific frames and save them either as a sequence of images or as a newly encoded video file.

Understanding the FFmpeg Select Command

To extract P-frames, you must use the select video filter combined with the pict_type constant. P-frames are represented by the character P.

Here is the standard command to extract P-frames as a sequence of PNG images:

ffmpeg -i input.mp4 -vf "select='eq(pict_type,P)',setpts=N/FRAME_RATE/TB" -fps_mode vfr output_%04d.png

Command Breakdown

Extracting P-Frames to a Video File

If you want to save the extracted P-frames as a continuous video clip rather than individual images, use the following command:

ffmpeg -i input.mp4 -vf "select='eq(pict_type,P)',setpts=N/FRAME_RATE/TB" -an output.mp4