2

My ultimate goal is to get meaningful snapshots from MP4 videos that are either 30 min or 1 hour long. "Meaningful" is a bit ambitious, so I have simplified my requirements.

The image should be crisp - non-overlapping, and ideally not blurry. Initially, I thought getting a keyframe would work, but I had no idea that keyframes could have overlapping images embedded in them like this:enter image description here

Of course, some keyframe images look like this and those are much better:

enter image description here

I was wondering if someone might have source code to:

Take a sequence of say 10-15 continuous keyframes (jpg or png) and identify the best keyframe from all of them.

This must happen entirely programmatically. I found this paper: http://research.microsoft.com/pubs/68802/blur_determination_compressed.pdf

and felt that I could "rank" a few images based on the above paper, but then I was dissuaded by this link: Extracting DCT coefficients from encoded images and video given that my source video is an MP4. Of course, this confuses me because the input into the system is just a sequence of jpg images.

Another link that is interesting is:

Detection of Blur in Images/Video sequences

However, I am not sure if this will work for "overlapping" images.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Carlos F
  • 893
  • 2
  • 12
  • 30
  • Sounds like a tough problem... – japreiss Feb 14 '13 at 15:37
  • Your problem is not well described, particularly what you mean by "overlapping" and "blurry" is not well defined in the question. Anyway, your problem is actually called video summarization, and the links you included are nearly irrelevant. Searching for that term will give many papers/ideas on how to do it. – mmgp Feb 14 '13 at 21:27
  • I thought it was fairly clear. By blurry - I mean motion blur. By overlapping images I mean like the one I included above. You see a lady overlapping a building. No, I do not want to do video summarization - I want a single keyframe or thumbnail from a video and I want to be sure it is not blurry (or overlapping). – Carlos F Feb 15 '13 at 00:11

1 Answers1

1

Th first pic is from a interlaced video at scene change.The two fields belong to different scenes. De-interlacing the video will help, try the ffmpeg filter -filter:v yadif . I am not sure how yadiff works but if it extracts the two fields and scale them to original size, it would work. Another approach is to detect if the two fields(extract alternate lines and form images with half the height and diff them) are very different from each other and ignore those images.

d33pika
  • 1,997
  • 14
  • 24
  • Tried this command : ffmpeg -ss 180 -i input.mp4 -vf "select=eq(pict_type\,I),thumbnail,yadif" -frames:v 10 -vsync vfr with_yadif%02d.jpg . Here is the first thumnail generated - https://docs.google.com/a/recordtv.com/file/d/0B_x2LZVyvfSWempBbUVGN1puUDQ/edit – Carlos F Feb 15 '13 at 09:29
  • Problem still exists even after yadif. thumnail has improved the screenshots taken.. but still, happens for few videos – Carlos F Feb 15 '13 at 09:35
  • The order of the command I used was wrong - your answer helped substantially. I will put the correct command in tomorrow. I did find one isolated image from about 50 that had an overlapping image. I am still trying to figure out how to find less blurred images. That said, the primary issue is substantially resolved. – Carlos F Feb 15 '13 at 12:26