Create a random thumbnail of a video file Looking at sites like YouTube, you may…
JWPlayer is a fantastic video player for the web. One of the great features it provides is the ability to show thumbnail previews of the video as you slide along the toolbar timeline, much the same way that YouTube and the like allow.
Generating the thumbnail images is not quite so easy unless you have ffmpeg installed and know a bit about the command line options. I got a little frustrated myself having to come up the with the command line magic whenever I needed it, and so the JW Player thumbnail preview generator was born!
It’s a simple command line tool, written in PHP, that allows you to whip up the thumbnails and generate the required VTT file with a command as simple as:
php thumbnails.php -i "/input/video.mp4"
OK, so you still need to have ffmpeg installed on your machine – not much I can do about that one, sorry! – but at least generating the files is now much easier!
You can generate the individual thumbnails or have them coalesced into sprite sheet, and generate a random poster image. Full instructions are on my GitHub account; so go, fork, improve, and feel free to give any feedback.