rsaavedra
rsaavedra

Reputation: 438

Extract final frame from a video using ffmpeg

I know how to extract the first frame by using

ffmpeg -ss 00:00:00 -i input.mp4 -vframes 1 -q:v 31 output.png

Here, the option -ss requires to know the exact time of the frame to extract.

I would like to have the final frame of any .mp4 without knowing the exact final time of the video.

Is there a way to achieve this?

Upvotes: 0

Views: 6151

Answers (1)

Gyan
Gyan

Reputation: 93329

Use

ffmpeg -sseof -3 -i file -vsync 0 -q:v 31 -update true out.jpg

-sseof seeks from the end - I've used a value of 3, to account for files with longer audio streams. -update is an image2 muxer option which tells ffmpeg to overwrite the output file. So the last time the output will be overwritten is when the last frame is processed.

Upvotes: 5

Related Questions