Take Screenshot from Video with FFmpeg
How to capture a frame from a selected timestamp of a video by using FFmpeg
Consider following case. You have a video file that you want to show a screenshot on a web page. But you don’t want to do it manually. Instead, you already have the exact time stamp of the video you want to take the screenshot.
It’s very simple to do that with FFmpeg. The following is the syntax to do that.
input.mp4 is the name of video file you want to take a screenshot of and
output.jpg is the output image file.
You can change the
-ss parameter and choose your own timestamp.
The format is
hh is the hour,
mm is the minute, and
ss is the second part of the timestamp.
In the example above, I choose the timestamp at 1 second after video start.
Take screenshots from multiple videos
You probably have multiple videos at home. You actually can take screenshot in batch mode. The following command can be used to take screenshot from multiple videos.
Simplify using Bash Function
To make the command easy to remember, you can also create a bash function out of it. The following snippet is the bash function I use at home.
With the previous bash function, the command can be simplified like following example.
As you can see, FFmpeg is very powerful video manipulation tool. You can do anything with it, the limit is your imagination.
Thank you for reading!