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

Luca Abeni lucabe72
Thu Mar 9 13:15:44 CET 2006


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 :)

			Thanks,
				Luca
-- 
_____________________________________________________________________________
Copy this in your signature, if you think it is important:
                               N O    W A R ! ! !

 
 
 --
 Email.it, the professional e-mail, gratis per te: http://www.email.it/f
 
 Sponsor:
 Premia il tuo migliore amico a 4 zampre: partecipa al concorso e vinci simpatici premi!
 Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=4875&d=9-3
-------------- next part --------------
A non-text attachment was scrubbed...
Name: crop-fix.diff
Type: text/x-patch
Size: 1383 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20060309/eb7a1b31/attachment.bin>



More information about the ffmpeg-devel mailing list