
Video/Image Conversion
A few commands to help convert between images and video, very handy for creating sample data sets when writing image processing tools.
Extract Images from a Video
The simple command below takes a video file (video.mpg
), extracts then outputs a series of images.
> ffmpeg -i video.mpg image%d.jpg
Combine Image into a Video
The command below will convert a set of PNG
images (*.png
) into a video (video.mpg
). Note
the printf
like format int the image name.
> ffmpeg -i img%d.png video.mpg
Note: FFmpeg
is very particular about the source image filenames. As
of version 0.5, if the image names are too complex you'll get a segmentation fault. So, if you have
a set of images with names like image_sample-0001-scaled.png
, you can convert them to
something more friendly using the following command.
> i=0; for img in image_sample*.png; do cp $img img$i.png; (( i++ )); done
References
The following links have some handy commands
The FFmpeg
website has some great examples of use:
