简体   繁体   中英

ffmpeg image generation in equal interval

I'm 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.(eg 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

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/

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM