[MPlayer-users] cropdetect filter crops too much

andrew at WARnux.com andrew at WARnux.com
Sat Dec 21 14:48:39 CET 2013


On 08/18/2013 11:28 AM, andrew at WARnux.com wrote:
> Has anyone else noticed that the cropdetect filter crops too much? I 
> assume it's happening because it's trying to keep 16 pixel alignment, 
> however, I would rather have small back bars than missing content.  In 
> my opinion, cropdetect should crop as much as it can, without cropping 
> content.  I don't have an example of this right now, but if you need 
> one, I can get it.
>
> Andrew
> _______________________________________________
> MPlayer-users mailing list
> MPlayer-users at mplayerhq.hu
> https://lists.mplayerhq.hu/mailman/listinfo/mplayer-users
>
>
I was consistently losing 8 scan lines of video when I depended upon the 
default behavior of the cropdetect filter.  Yesterday I was tired of 
waiting for a fix in mplayer (where the fix should be) so I came up with 
a work-around:

Use this when passing in the filter to mplayer:
----
cropdetect=24:2
----

Use code similar to this when parsing the crop rectangle that mplayer 
spits out:
----
//rect - Crop rectangle from mplayer.
//s - A string that is holding the mplayer crop parameters.
//vw / vh - Video source width and height.

#define RoundUpMult16(n) (((n*2+31)/32)*16)
int wDiff16= RoundUpMult16(rect.w)-rect.w;
int hDiff16= RoundUpMult16(rect.h)-rect.h;

if(wDiff16)
{
     rect.x -= wDiff16/2;
     rect.w += wDiff16;

     if(rect.w%16 || rect.x < 0 || rect.w > vw)
     {
         cout << "Width not mult of 16 or out of bounds; unsetting\n";
         rect.x= 0; rect.w= vw;
     }
}
if(hDiff16)
{
     rect.y -= hDiff16/2;
     rect.h += hDiff16;

     if(rect.h%16 || rect.y < 0 || rect.h > vh)
     {
         cout << "Height not mult of 16 or out of bounds; unsetting\n";
         rect.y= 0; rect.h= vh;
     }
}
s.App(rect.x); s.App(','); s.App(rect.y); s.App(','); s.App(rect.w); 
s.App(','); s.App(rect.h);
----

Andrew


More information about the MPlayer-users mailing list