Convert .mkv video to .png images using ffmpeg
Note: This tutorial will also work in Kubuntu, Lubuntu, Xubuntu, Ubuntu Gnome, Ubuntu Mate, Linux Mint and other Ubuntu Based Distributions.
One of my passions is playing old retro computer games, these can be found over at my other site Retro Gas
Whenever I add a new game, I always try to provide a small video and screenshots of the game for users visiting the site.
As you can imagine, getting just one game listed on the site is quite a task. When I first started adding games to my site, I needed a way to grab screenshots from the video I recorded.
After much searching and lots of trial and error, I found a software package for Linux called ffmpeg.
ffmpeg is cross platform solution to record, convert and stream audio and video. You can visit the main ffmpeg site here
As I use an Ubuntu based distribution, I first needed to install the package.
To install ffmpeg enter the following command in the terminal
sudo apt-get install ffmpeg
After this I created a new folder on my desktop and dragged my .mkv video file in to it. The reason for this, is that I wanted all .png files in one folder and not scattered across the desktop. If your outputting 1 frame per second that is a lot of images.
The next step was to CD to the directory that contains the .mkv file
Then run the following command to output the .png images
ffmpeg -i filename.mkv -vf fps=1 filename_%d.png
The command above outputs one .png
file from the .mkv file every second.
created also follows a numerical sequence because of %d
in the command, example filename_1.png, filename_2.png, filename_3.png and so on......
Remember to replace filename with your own file names.