I am trying to generate 8 screenshots for an uploaded video using FFMPEG. I currently have:
ffmpeg -i Trailer-720p.mov -r .2 -vcodec png Preview-%d.png
Which generates a screenshot every 5 seconds. How can I add the ability to generate a screenshot for frames distributed over a percentage of total time. Thanks. Furthermore, is it possible to generate a screenshot at 50% for example? Thanks.
If you run ffmpeg with just the -i parameter, it will provide you with the length of the video on stderr (among lots of other things). You could write something around that, converting the duration and the intended number of frames into the correct -r parameter.
Here is an quick example in python which basically does what I have described. For some reason the first two stills generated by my version of ffmpeg both show frame 0, but Preview-3 to Preview-n are in the correct intervals. Run it with the second parameter set to '1' and it will generate the middle frame as Preview-3.png.
I could not get Manfred Stienstra's brilliant oneliner to generate frames at the exact right spot. If I specified to generate 8 images from a 240 secs movie, the first one would be 15, the second at 45, etcetera. I wanted the first one to be 0, the second at 30, etcetera.
So I took his oneliner apart and created this
Here's one in Ruby:
Or just with a shell command:
This creates 10 thumbnails with the same dimensions as the source video.