Convert Video to Images and Back Using FFMPEG

I’ve used this technique to get lightning shots that I’ve gotten from my video camera. This will help you get static pictures from any video clip. You can also manipulate the images and convert them back into a video clip!

I am running Ubuntu Linux, but these commands may also work with the Windows version of FFMPEG. Use at your own risk.

First, lets make a directory to put them in since we are all organized.

mkdir ffmpeg_temp

Now, let’s run the command to make the pictures from a video. This next command will take the video, video.mpg in the current directory, convert it into images, and place them into the directory created with the above command. If you want a frame rate other than 1 frame /sec, modify the -r switch.

ffmpeg -i video.mpg -r 1 -f image2 ffmpeg_temp/%05d.png

You now have all the images in the ffmpeg_temp directory. Yay!

Now what if you want to convert it back? Just run the command below. If you changed the directory name that was specified above, make sure that you modify the command accordingly.

ffmpeg -i ffmpeg_temp/%05d.png -b 512 video2.mpg

This post was a variation on my tutorial on creating a time lapse video using FFMPEG.

This entry was posted on Wednesday, September 5th, 2007 at 12:28 pm and is filed under Linux. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

4 Responses to “Convert Video to Images and Back Using FFMPEG”

Let Search Engines Help When Out of Blogging Ideas | Pr0gr4mm3r September 6th, 2007 at 12:54 pm

[...] up with that set of keywords. I had no blog entry that explained how to convert a video to images, but I do now, because I saw that the search engines were already sending people over here that wanted that [...]

1blog April 23rd, 2011 at 3:29 am

if you want to have only images every “n” seconds than use this:

Chris June 5th, 2011 at 1:37 pm

mplayer -vo jpeg or mplayer -vo png also works

abeer January 12th, 2012 at 2:23 pm

im a beginner in using ffmpeg, and i want to use it to extract the I- ,P- frame types from a video, can u please help me? please

Leave a Reply