[MEncoder-users] Suggestions for auto-crop-detect methods?

Joe Emenaker joe at emenaker.com
Fri Jan 12 00:52:47 CET 2007


About a year or two ago, when I started tinkering with dvd ripping on 
Linux, I came across a script that a lot of people seemed to recommend 
called "dvdrip" or maybe "dvd:rip". Overwhelmed by the number of options 
and stuff, I decided to write my own that did only what I wanted....

... and then I gradually discovered that I needed to tweak a lot of the 
options that had frightened me so much when I first looked at dvd:rip. 
Ah well... at least I understand a little of what the options do now.

Anyway, the part I'm tweaking now is a part that watches some portion of 
the DVD for about 1000 frames with "mplayer -vf cropdetect" to figure 
out the cropping.

When I first tried cropdetect, I expected it to read the movie... and 
then burp out what cropping to use. Instead, it burps out what cropping 
to use for *every* frame.... so you have to sort through all of it to 
figure out the best cropping.

Until yesterday, the way I had dealt with this was to have my script 
record the number of times mplayer produced a given 
"width:height:left:top" set of numbers, and then use the most-common one 
(so I'll call this the "most common" selection method). This worked 
pretty well until yesterday, when I was ripping a movie that had very 
dark scenes at the beginning, so my crop settings ended up being the 
size of the opening credits.

What I did to solve this was to, for each cropdetect line, translate 
each "width:height:left:top" set into left, right, top, and bottom 
numbers.... and then record the smallest left and top numbers and the 
largest right and bottom numbers (I'll call this the "furthest borders" 
method). This seems to be working better. However, I've got a few 
worries about it. One of these is that a brief full-screen copyright 
warning can eliminate the cropping.

Also, I have become concerned with the number of frames needed in order 
to do the crop detection. Previously, whenever the crop-detection failed 
(using the "most common" method), I merely increased the number of 
frames that mplayer read, to make sure that mplayer was seeing a nice 
big chunk of the real movie. But this is getting out of hand. I'm now 
reading 1800 frames, which consumes about a minute just for frame detection.

So, I had a different idea. I could read fewer frames, but from various 
places throughout the movie; specifically, from the chapter points. I 
could read, say, 30-90 frames from each of the first 20 chapters. So 
then, my only question is: which crop selection method do I use? I can 
actually use both. I could use, say, the "furthest borders" method to 
get crop settings at any given chapter point... and then use "most 
common" to choose from the settings deduced at *all* of the chapter 
points. It's a thought... anyway.

So, I figure that somebody out there has already done a lot of 
experimentation with this... and they might already know the best way to 
do auto crop-detection. So, to anybody who knows.... am I on the right 
track, or is there some other method or script that I should just use 
and forget about this?

- Joe


More information about the MEncoder-users mailing list