Use FFMPEG to Extract an Image from a Video Every N Seconds

I have videos from which I need to extract a screenshot of the video every 5 seconds. So I need a screenshot of the video at 00:05, 00:10, 00:15, and so on.

This can be accomplished using the following command with FFMPEG.

$ ffmpeg -i video.mp4 -vf fps=1/5 -qscale:v 2 video-%d.jpg

FFMPEG itself cannot use wildcards for the file names, so it cannot be used by itself to automatically run this process on every MP4 in a directory. However, it would be fairly easy to write a script that would accomplish this in Bash or Python.

Downloading YouTube Videos With YouTube-DL + FFmpeg

YouTube-DL is an open source, command-line program to download videos from YouTube. The GitHub repository contains a downloadable Windows executable.

FFmpeg is an open source “cross-platform solution to record, convert and stream audio and video.” A Windows executable version of FFmpeg can be downloaded from FFmpeg Builds.

I am primarily a Windows user, so I create a /youtube-dl/ subdirectory in my /downloads/ directory.

Then I put the YouTube-DL and FFmpeg executables in that directory.

To download the highest quality version of a YouTube video, I run CMD, navigation to the /downloads/youtube-dl/ directory, and use this:

> youtube-dl -f bestvideo+bestaudio --merge-output-format mkv [YouTube URL]

If the [YouTube URL] is a link to a YouTube playlist, YouTube-dl will helpfully download the entire playlist.