[Ffmpeg-devel] Probable crop bug (with patch)

Michael Niedermayer michaelni
Thu Mar 9 14:26:19 CET 2006


Hi

On Thu, Mar 09, 2006 at 01:15:44PM +0100, Luca Abeni wrote:
> Hi all,
> 
> what can I say... I fell in love with those "-crop*" options ;-)
> 
> Anyway, let's assume I want to remove 100 lines from the top of a
> 352x288 video, and 100 from the bottom, and then I want to rescale it to
> its original size...
> The (hopefully correct) command line is
> ffmpeg -i in.y4m -croptop 100 -cropbottom 100 -s 352x288 out.y4m
> (352x288 is the original size).
> 
> But this does not work (no cropping nor rescaling is performed). You can
> reproduce this with
> ./output_example in.y4m
> ffmpeg -i in.y4m -croptop 100 -cropbottom 100 -s 352x288 out.y4m
> and looking at the resulting out.y4m: it is identical to in.y4m.
> 
> If you look at line 1738 & following of ffmpeg.c you can understand why:
> ...
> } else if ((codec->width == icodec->width +
>                                 (frame_padleft + frame_padright)) &&
>                         (codec->height == icodec->height +
>                                 (frame_padtop + frame_padbottom))) {
>                     ost->video_resample = 0;
>                     ost->video_crop = 0;
>                     ost->video_pad = 1;
> ...
> 
> Since codec->width == icodec->width, codec->height == icodec->height
> (the output size is equal to the input size), and frame_pad* == 0 (no
> padding is performed), the condition is true and ffmpeg thinks that no
> cropping nor rescaling is needed...
> Adding an explicit test for frame_pad* != 0 fixes the problem.
> 
> The attached patch fixes this bug, + a similar one encountered when
> padding. In fact, after applying the patch the command line presented
> above works as expected.
> 
> Do you think that the patch is correct? I hope I did not get it wrong
> again :)

just apply it and we will see ...

[...]

-- 
Michael





More information about the ffmpeg-devel mailing list