Search code examples
ffmpegh.264video-processing

How to extract only 3 video frames at 0,5,10 seconds using FFMPEG?


Command I am using:

ffmpeg -i input -c:v libx264 -movflags +faststart -preset slow -crf 22 -b:v 500k -c:a libvo_aacenc -b:a 128k "out.mp4" -r 1 -t 3 -ss 3 -s sqcif "%%1d.jpg"

Solution

  • Use the select filter:

    ffmpeg -i input.mp4 -vf "select='eq(t,0)+eq(t,5)+eq(t,10)'" -vsync vfr output_%03d.png
    

    -vsync vfr will prevent it from outputting unwanted, duplicate frames.