How to convert a video into images

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
msaad99
Posts: 3
Joined: 2012-06-09T04:21:38-07:00
Authentication code: 13

How to convert a video into images

Post by msaad99 »

Im working in Matlab and i want to convert the frames of an avi video into separate images. and then i want to use all those frames to match them with some other images. Can anyone please tell how i can do that using imagemagick?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How to convert a video into images

Post by fmw42 »

msaad99 wrote:Im working in Matlab and i want to convert the frames of an avi video into separate images. and then i want to use all those frames to match them with some other images. Can anyone please tell how i can do that using imagemagick?

Converting all frames of a video to images would take a lot of resources. I do not believe that IM allows you to skip or jump. Nevertheless, see http://www.imagemagick.org/Usage/video/

Probably just

convert video.avi image.png

You did not say what output format you want.

As for comparing images, that can be done, but one image at a time or via a script that loops over each video image and compares to your reference image.

compare -metric rmse video_frame referenceimage null:

will report the rmse difference. You can choose other metrics. Note the above requires the two images to be the same size. There is another option (-subimage-search) that allows you to match a smaller reference to the videoframe and find out where it best matches within the videoframe.

see
http://www.imagemagick.org/script/compare.php
http://www.imagemagick.org/Usage/compare/
rich2005
Posts: 32
Joined: 2012-04-09T11:07:36-07:00
Authentication code: 8675308

Re: How to convert a video into images

Post by rich2005 »

As well as the above

To decompose an avi file to individual frames you can use ffmpeg on a command line.

The windows version of imagemagick comes with its own (slim) version, if you use linux there will be (a better version) in your distro repository.

the command is;

ffmpeg -i inputfile.avi -f image2 image-%07d.png (or you could use .jpg)

Best to put the inputfile.avi in an empty folder and run the command from there as even the smallest video will have lots of frames.

Not guaranteed as the avi format is just a wrapper and covers a multitude of sins.
huyandhang
Posts: 1
Joined: 2012-06-10T21:21:37-07:00
Authentication code: 13

Re: How to convert a video into images

Post by huyandhang »

Its useful. Thank for all share!
___________________________________________________________________________________________________________________________________________________

Click here | Home page

super mario bros games | super mario games online
Last edited by huyandhang on 2012-06-20T07:10:19-07:00, edited 2 times in total.
msaad99
Posts: 3
Joined: 2012-06-09T04:21:38-07:00
Authentication code: 13

Re: How to convert a video into images

Post by msaad99 »

[/quote]Converting all frames of a video to images would take a lot of resources. I do not believe that IM allows you to skip or jump. Nevertheless, see http://www.imagemagick.org/Usage/video/

Probably just

convert video.avi image.png

You did not say what output format you want.

As for comparing images, that can be done, but one image at a time or via a script that loops over each video image and compares to your reference image.

compare -metric rmse video_frame referenceimage null:

will report the rmse difference. You can choose other metrics. Note the above requires the two images to be the same size. There is another option (-subimage-search) that allows you to match a smaller reference to the videoframe and find out where it best matches within the videoframe.

see
http://www.imagemagick.org/script/compare.php
http://www.imagemagick.org/Usage/compare/[/quote]


Thanks. Im new to all this so im having these problems. can you please tell me how to set a path to where my images are located?
msaad99
Posts: 3
Joined: 2012-06-09T04:21:38-07:00
Authentication code: 13

Re: How to convert a video into images

Post by msaad99 »

Thanks. Im new to all this so im having these problems. can you please tell me how to set a path to where my images are located?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How to convert a video into images

Post by fmw42 »

msaad99 wrote:Thanks. Im new to all this so im having these problems. can you please tell me how to set a path to where my images are located?

Either use cd command to change to that directory or preface each image with its path to the directory it resides.

cd path2images

convert yourimage ....

or

convert path2images/yourimage
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: How to convert a video into images

Post by anthony »

Also see the Common Image File Formats Section.. MPEG, M2V and AVI Movies
http://www.imagemagick.org/Usage/formats/#mpeg


Long answer short --- mplayer/mencode will do the deed.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply