Extract frames from a video

Extract a still frame

To grab a frame at a certain time, use this:

ffmpeg -ss 00:00:01 -i input.mpeg4 -vframes 1 -q:v 2 output.jpg

To grab the last frame, use ffprobe to figure the length of the video first. You can use the following script and pass the filename of the video as an argument:


frame_count=`ffprobe -v error -count_frames -select_streams v:0 -show_entries stream=nb_read_frames -of default=nokey=1:noprint_wrappers=1 $1`
ffmpeg -i $1 -vf "select='eq(n,$frame_count-1)'" -vframes 1 "$1.png" 2> /dev/null