Search code examples
ffmpeg

Get with ffmpeg first and last frame images


It is possible to get first and last frames with using ffmpeg and only one system call?

If I know duration ffmpeg -ss 00:00:00 -i input.mov -vf fps=1/duration -vframes 2 -q:v 1 -qmin 1 out%2d.jpg is working but not right. But I need second system call for recieving duration video.


Solution

  • ffmpeg has an option to seek relative to the end. You can use that to get to the last frame. To make this efficient, we will use the source as an input twice.

    ffmpeg -i input.mov -sseof -1 -i input.mov -map 0:v -vframes 1 -q:v 1 -qmin 1 first.jpg -map 1:v -q:v 1 -qmin 1 -update 1 last.jpg