notbrainsurgery (notbrainsurgery) wrote,
notbrainsurgery
notbrainsurgery

Poor Man Video Thumbnail Generation

If you are building yet another YouTube-like service, eventually, you will be facing the problem of generating thumbnails for video clips. The simplest solution would be to get some random or fixed frame, and use is a thumb. Unfortunately, this does not always produce best results. You can try to implement more sophisticated algorithms, like described here (Quote: "The shot and key frame are selected based on measures of motion and spatial activity and the likeliness to include people. The latter is determined by skin-color detection and face detection."). I did not have time and patience to implement such complex algorithms, so I came up with one of my own, which is really simple, could be implemented in couple of hundreds lines of code and works pretty well.

The main idea is very simple: we analyze first few seconds of a clip and build histograms of color distribution per frame. Then, we average them, building an averaged color distribution histogram. Then we find a frame, which is closest to the average value (I am using RMSE to estimate "closeness"). We select a frame close to beginning of the video, which makes selection process faster (less frames to examine) and less likely to include spoilers. Selected picture is similar in color distribution to the overall video theme, making it more likely to display typical frame.

I run it on few hundreds video clips, and it shows pretty good results. Of course, these results are not representative, I've selected most interesting ones but generally I think it is very usable. You can grab the source code and try it yourself.
Tags: algorithm, image, python, thumbnail, video
Subscribe

  • Android keyboard

    Switching between Nexus One and iPhone I could not help noticing that my typing error rate is significantly lower with iPhone. Both devices have…

  • furl.net -> del.icio.us

    I am using FURL as my primary bookmark manager. The most attractive feature to me is that it saves the actual copy of a page as I have seen it. So…

  • python scoping

    Take a look at the following Python code: class X: def x(self): print b #b=2 b=1 X().x() It compiles and runs just fine. However if you would…

  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 6 comments