Take a screenshot of a video using ffmpeg

23 May 2023 in TIL

I needed to extract a frame at the same time for multiple videos (the title slide for a TV show) to help make sure that the filenames reflected the episode the file contained. ffmpeg made it super-easy.

To take a single screenshot:

bash
ffmpeg -ss 00:00:51 -i video.mp4 -frames:v 1 -q:v 2 output.jpg

To take a screenshot of all videos in a folder and name the output file based on the input file:

bash
for i in `ls`; do ffmpeg -ss 00:00:51 -i $i -frames:v 1 -q:v 2 /tmp/screenshots/$i.jpg; done