How to extract keyframe and p-frame from stream with single command using ffmpeg

ffmpegvideo

I want to extract two kind of frames from a tv stream using ffmpeg at the same time.

My question is how can I get two two I and P frames using one single command?

e.g : command to get all keyframes in ffmpeg :

ffmpeg -i http://my-tv-stream.m3u8 -vf "select=eq(pict_type\,I)" -vsync vfr -qscale:v 2 thumbnails-%02d.jpeg

Best Answer

Use

ffmpeg -i http://my-tv-stream.m3u8 -vf "select='eq(pict_type\,I)+eq(pict_type\,P)'" -vsync vfr -qscale:v 2 thumbnails-%02d.jpeg

To output the frame types separately, use

ffmpeg -i http://my-tv-stream.m3u8 -vf "select='eq(pict_type\,I)" -vsync vfr -qscale:v 2 I-thumbnails-%02d.jpeg
       -vf "select='eq(pict_type\,P)" -vsync vfr -qscale:v 2 P-thumbnails-%02d.jpeg
Related Question