[FFmpeg-user] Remove two lines from the bottom of the video

Moritz Barsnick barsnick at gmx.net
Mon Feb 2 13:51:16 CET 2015


Hi Wesley,

On Mon, Feb 02, 2015 at 10:51:12 +0000, Wesley Wen wrote:
>     Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 426x240 [SAR 149:181 DAR 10579:7240], 80 kb/s, SAR 12800:15549 DAR 320:219, 29.97 fps, 29.97 tbr, 30k tbn, 59.94 tbc (default)

I have always found those AR numbers a little peculiar, but refused to
look at the code creating them. ;-)

But this results from your scaling to 426x240, not from the cropping.

> Input #0, mpeg, from 'sample.mpg':
>   Duration: 00:24:28.18, start: 0.262000, bitrate: 8597 kb/s
>     Stream #0:0[0x1e0]: Video: mpeg2video (Main), yuv420p(tv), 720x480 [SAR 8:9 DAR 4:3], 8000 kb/s, 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc
>     Stream #0:1[0x1c0]: Audio: mp2, 48000 Hz, stereo, s16p, 384 kb/s
> 
> And here is the command I used to do crop.
> ffmpeg -y -i sample.mpg -c:v libx264 -b:v 80k -vf crop=720:438:0:0,scale=426:240 out.mp4

Excuse me? You write you want to remove two lines, but you are removing
42. Nice number, but different result! (480 - 438 = 42.) Did you
complain about the non-4:3 AR, or that your image is peculiarly
stretched? The latter would be due to your miscalculation.

> I'd like to keep display aspect ratio as 4:3, and remove those two green
> lines or fill black.

Well if you snip away something in one dimension, you are going to ruin
the aspect ratio. So you either need to snip accordingly in each
dimension (e.g. 4 columns horizontally, 3 lines vertically), or stretch
to refill the original dimensions, or fill up with something else such
as black.

Since filling with black is okay for you, let me suggest cutting away
(i.e. "crop"ping) and filling back up (i.e. "pad"ding):

$ ... -vf "crop=720:478:0:0,pad=720:480:0:0,scale=426:240"

(I think both former filters default to ":0:0", check the docs.)

Let us know if this helps,
Moritz


More information about the ffmpeg-user mailing list