tags:

views:

531

answers:

2

hi plz help

im using ffmpeg in Ubuntu for the image creation and video conversion my problem is i want to generate image(thumbnail) at different intervals. suppose that i upload a video then it calculate the video time and generate 5 images(thumbnail) at equal intervals.(e.g. suppose that the time period of the video is 50 minutes then images obtains at 0,10,20,30,40,50 intervals)

please help

thanks

+3  A: 

Short version:

ffmpeg -itsoffset -4 -i test.avi -vcodec mjpeg -vframes 1 -an -f rawvideo -s 320x240 test.jpg

This command generates a 320×240 sized PNG thumbnail at the 4th second in the video. Put this in a script that changes the time and file name and you're done .

Long version: http://blog.prashanthellina.com/2008/03/29/creating-video-thumbnails-using-ffmpeg/

Nifle
no the concept is diffrent suppose that my video duration length is 60 minutes then every image obtained should be in every 12 minute so the video duration is variable
vipinsahu
Find out the video duration and divide it by the amount of pictures you want to have.
Georg
how can i do this plz help
vipinsahu
**ffmpeg -i test.avi** will dump info about the video. Parse that data to get video duration
Nifle
+2  A: 

Well if you just run:

ffmpeg -i file.mp4

The output will contain the length of the video on stderr. If you run your program and pipe its output to a file you can read it or if you'd prefer you can read the output of stderr and just write some code in whatever language you're using to find the position in that output. It's pretty because I believe it's actually in the string as "Duration: 00:15:00" or whatever.

If you run:

ffmpeg -ss 00:03:00 -i test.avi -vcodec mjpeg -vframes 1 -an -f rawvideo -s 320x240 test.jpg
ffmpeg -ss 00:06:00 -i test.avi -vcodec mjpeg -vframes 1 -an -f rawvideo -s 320x240 test.jpg
ffmpeg -ss 00:09:00 -i test.avi -vcodec mjpeg -vframes 1 -an -f rawvideo -s 320x240 test.jpg
ffmpeg -ss 00:12:00 -i test.avi -vcodec mjpeg -vframes 1 -an -f rawvideo -s 320x240 test.jpg
ffmpeg -ss 00:15:00 -i test.avi -vcodec mjpeg -vframes 1 -an -f rawvideo -s 320x240 test.jpg

Then you'll have frames as jpegs every 3 minutes. Hope this helps.

Jon
ya john thanks but my problem is little different i want to extract 5 images from the videos at equal interval whatever may be the length of the video
vipinsahu
Well you'd just that duration you calculated earlier in your program and then loop in even intervals to get your thumbnails. You won't be able to do this without writing some code (as far as I know at least).
Jon