[MPlayer-users] Aspect Ratio in vfilters
Alexander Roalter
alex at roalter.it
Tue Mar 13 12:09:10 CET 2007
RC wrote:
> On Tue, 13 Mar 2007 10:59:34 +0100
> Alexander Roalter <alex at roalter.it> wrote:
>
>> But I don't know how to get the desired aspect ratio from the video in
>>
>> the filters, since they seem to operate entirely on the image before
>> stretching and resizing. Any way to do that?
>
> IIRC, you're probably looking for d_width/d_height.
Thank you, that helped a lot. Got it finally working now, this is how
I've done it (in case anyone is interested):
diff vf_cropdetect.c old vs. new:
20a21
> float aspect;
54a56,59
> if (d_height == 0)
> vf->priv->aspect = 1;
> else
> vf->priv->aspect = (float)d_width/(float)d_height;
59a65,66
> float ratio;
> float stretch;
129,133c136,151
<
< mp_msg(MSGT_VFILTER, MSGL_INFO, MSGTR_MPCODECS_CropArea,
< vf->priv->x1,vf->priv->x2,
< vf->priv->y1,vf->priv->y2,
< w,h,x,y);
---
> ratio = (((float)(vf->priv->x2 - vf->priv->x1 + 1))/
> ((float)(vf->priv->y2 - vf->priv->y1 + 1)));
> if ((mpi->height == 0) || (mpi->width == 0))
> stretch = 1;
> else
> stretch = vf->priv->aspect / ((float)mpi->width/
(float)mpi->height);
>
> mp_msg(MSGT_VFILTER, MSGL_INFO, MSGTR_MPCODECS_CropArea,
> vf->priv->x1,vf->priv->x2,
> vf->priv->y1,vf->priv->y2, ratio * stretch,
> w,h,x,y);
>
> // mp_msg(MSGT_VFILTER, MSGL_INFO, MSGTR_MPCODECS_CropArea,
> // vf->priv->x1,vf->priv->x2,
> // vf->priv->y1,vf->priv->y2,
> // w,h,x,y);
And in help/help_mp-en.h (and it should be done in any other language...)
1654a1654
< #define MSGTR_MPCODECS_CropArea "[CROP] Crop area: X: %d..%d Y:
%d..%d (-vf crop=%d:%d:%d:%d).\n"
> #define MSGTR_MPCODECS_CropArea "[CROP] Crop area: X: %d..%d Y:
%d..%d R:%0.2f:1 (-vf crop=%d:%d:%d:%d).\n"
Maybe someone can use it to some avail. I wouldn't miss it.
cheers,
Alex
More information about the MPlayer-users
mailing list