Sunday, June 6, 2010

FFmpeg: Convert AVI file to series of PNG/JPG images

Extracting a movie file frame by frame and create images (png, jpg) of it. You can set the the frame rate, on how frequent you want an image extracted. Example, if you want to extract 1 image per sec, your rate is 1, if you want to extract every frame of the movie, your frame rate = frame rate of movie.
This technique is used to do a loss-less video editing in tools as Blender, were you can import a sequence of images. This procedure can be very time consuming for long video's, but the quality after editing rewards you for it.
Lets say you do a screen-capture, on a canvas of 1024x768, and created an AVI file with a frame rate of 15 frames per second. (typical for screen casts) you want every frame to be written out as an png-image file, where the numbering is expected to run up to 5 digits. (%05d - option will allow for numbers 5 digits long, padded with zero's)
The command line to do this would look as follows:


Command @ Terminal Screen:

ffmpeg -i input_file.avi -r 15 -s 1024x768 -f image2 output-file-%05d.png



EXTRA:You can also include other ffmpeg parameters as in following example. (Dealing with interlaced material)

ffmpeg -i Raw.Videofile.m2ts -deinterlace -r 0.1 -s 1920x1080 -f image2 img%05d.png


Note the frame rate!:
You can drastically reduce the amount of snapshots taken by using small frame-rates. This setting is great to create a picture set with snapshots of your video.

No comments:

Post a Comment

Please be courteous, even if you do not share the same view.