Why does padding (after crop/scale) seem to compress this video horizontally?

  Input #0, mpeg, from 'TEMP-original.vob':
    Duration: 01:24:52.03, start: 0.287267, bitrate: 5841 kb/s
      Stream #0:0[0x1e0]: Video: mpeg2video (Main), yuv420p(tv, top first), 
720x576 [SAR 16:15 DAR 4:3], 25 fps, 25 tbr, 90k tbn, 50 tbc
      Stream #0:1[0x80]: Audio: ac3, 48000 Hz, stereo, fltp, 224 kb/s

The actual video part (not including black bars) is (704:416:2:82) according to cropdetect.

I'd like to end up with a video that's cropped to 704:416:2:82, scaled to 720x-1, padded to 720x480 with black bars only on the top/bottom, and a DAR of 16:9 instead of 4:3. Not necessarily in that order... I'm not sure of the "correct" filter order.

If all I do is crop the video to 704:416:2:82 it looks fine compared to the original (complete output below):

  $ ffmpeg -i TEMP-original.vob -codec:v mpeg2video -b:v 16384k -bufsize 4096k 
-maxrate 30000k -codec:a copy -vf crop=704:416:2:82 -t 60 -f vob TEMP-crop.mpg

If I crop and scale to 720x-1 it still looks fine (complete output below):

  $ ffmpeg -i TEMP-original.vob -codec:v mpeg2video -b:v 16384k -bufsize 4096k 
-maxrate 30000k -codec:a copy -vf crop=704:416:2:82,scale=720:-1 -t 60 -f vob 
TEMP-crop-scale.mpg

BUT, if I try to crop, scale and pad the top/bottom to 720x480, then the video is compressed horizontally (complete output below):

  $ ffmpeg -i TEMP-original.vob -codec:v mpeg2video -b:v 16384k -bufsize 4096k 
-maxrate 30000k -codec:a copy -vf 
crop=704:416:2:82,scale=720:-1,pad=720:480:0:27 -t 60 -f vob 
TEMP-crop-scale.pad.mpg

FYI. The crop/scale ends up as 720x425, so to get to 720x480 I pad top with 27 (480-425/2 = 27.5).

Why does padding cause the video to be compressed horizontally and more importantly, how can I convert the original to 720x480 with bars only on the top/bottom, DAR of 16/9, WITHOUT distorting the video?


-------------------------------------------------------------------------------
Complete output for all 3 example commands
-------------------------------------------------------------------------------

Crop to "cropdetect" size (704:416:2:82)
This looks fine (via ffplay) compared to original - it is not distorted

  $ ffmpeg -i TEMP-original.vob -codec:v mpeg2video -b:v 16384k -bufsize 4096k 
-maxrate 30000k -codec:a copy -vf crop=704:416:2:82 -t 60 -f vob TEMP-crop.mpg
  ffmpeg version N-96491-g4b4bcb126c Copyright (c) 2000-2020 the FFmpeg 
developers
    built with gcc 9 (GCC)
    configuration: --enable-gpl --enable-version3 --enable-nonfree 
--enable-static --disable-shared --disable-debug --enable-libass 
--enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus 
--enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 
--enable-libx265 --enable-openssl --enable-libbluray --enable-libcdio
    libavutil      56. 38.100 / 56. 38.100
    libavcodec     58. 66.101 / 58. 66.101
    libavformat    58. 35.104 / 58. 35.104
    libavdevice    58.  9.103 / 58.  9.103
    libavfilter     7. 71.100 /  7. 71.100
    libswscale      5.  6.100 /  5.  6.100
    libswresample   3.  6.100 /  3.  6.100
    libpostproc    55.  6.100 / 55.  6.100
  Input #0, mpeg, from 'TEMP-original.vob':
    Duration: 01:24:52.03, start: 0.287267, bitrate: 5841 kb/s
      Stream #0:0[0x1e0]: Video: mpeg2video (Main), yuv420p(tv, top first), 
720x576 [SAR 16:15 DAR 4:3], 25 fps, 25 tbr, 90k tbn, 50 tbc
      Stream #0:1[0x80]: Audio: ac3, 48000 Hz, stereo, fltp, 224 kb/s
  Stream mapping:
    Stream #0:0 -> #0:0 (mpeg2video (native) -> mpeg2video (native))
    Stream #0:1 -> #0:1 (copy)
  Press [q] to stop, [?] for help
  Output #0, vob, to 'TEMP-crop.mpg':
    Metadata:
      encoder         : Lavf58.35.104
      Stream #0:0: Video: mpeg2video (Main), yuv420p, 704x416 [SAR 16:15 DAR 
352:195], q=2-31, 16384 kb/s, 25 fps, 90k tbn, 25 tbc
      Metadata:
        encoder         : Lavc58.66.101 mpeg2video
      Side data:
        cpb: bitrate max/min/avg: 30000000/0/16384000 buffer size: 4096000 
vbv_delay: N/A
      Stream #0:1: Audio: ac3, 48000 Hz, stereo, fltp, 224 kb/s
  [mpeg @ 0x21833c0] New subtitle stream 0:2 at pos:6678542 and 
DTS:20.2873sbits/s speed=20.8x
  [mpeg @ 0x21833c0] New subtitle stream 0:3 at pos:7571470 and DTS:22.5673s
  frame= 1500 fps=489 q=2.0 Lsize=   34656kB time=00:00:59.96 
bitrate=4734.2kbits/s speed=19.6x
  video:32580kB audio:1641kB subtitle:0kB other streams:0kB global headers:0kB 
muxing overhead: 1.272054%

  $ ffmpeg -hide_banner -i TEMP-crop.mpg
  Input #0, mpeg, from 'TEMP-crop.mpg':
    Duration: 00:01:00.00, start: 0.540000, bitrate: 4731 kb/s
      Stream #0:0[0x1e0]: Video: mpeg2video (Main), yuv420p(tv, progressive), 
704x416 [SAR 104:99 DAR 16:9], 25 fps, 25 tbr, 90k tbn, 50 tbc
      Stream #0:1[0x80]: Audio: ac3, 48000 Hz, stereo, fltp, 224 kb/s
  At least one output file must be specified


Crop to "cropdetect" size (704:416:2:82) and scale to 720x-1 (ends up as 
720x425)
This still looks fine (via ffplay) compared to original - it is not distorted

  $ ffmpeg -i TEMP-original.vob -codec:v mpeg2video -b:v 16384k -bufsize 4096k 
-maxrate 30000k -codec:a copy -vf crop=704:416:2:82,scale=720:-1 -t 60 -f vob 
TEMP-crop-scale.mpg
  ffmpeg version N-96491-g4b4bcb126c Copyright (c) 2000-2020 the FFmpeg 
developers
    built with gcc 9 (GCC)
    configuration: --enable-gpl --enable-version3 --enable-nonfree 
--enable-static --disable-shared --disable-debug --enable-libass 
--enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus 
--enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 
--enable-libx265 --enable-openssl --enable-libbluray --enable-libcdio
    libavutil      56. 38.100 / 56. 38.100
    libavcodec     58. 66.101 / 58. 66.101
    libavformat    58. 35.104 / 58. 35.104
    libavdevice    58.  9.103 / 58.  9.103
    libavfilter     7. 71.100 /  7. 71.100
    libswscale      5.  6.100 /  5.  6.100
    libswresample   3.  6.100 /  3.  6.100
    libpostproc    55.  6.100 / 55.  6.100
  Input #0, mpeg, from 'TEMP-original.vob':
    Duration: 01:24:52.03, start: 0.287267, bitrate: 5841 kb/s
      Stream #0:0[0x1e0]: Video: mpeg2video (Main), yuv420p(tv, top first), 
720x576 [SAR 16:15 DAR 4:3], 25 fps, 25 tbr, 90k tbn, 50 tbc
      Stream #0:1[0x80]: Audio: ac3, 48000 Hz, stereo, fltp, 224 kb/s
  Stream mapping:
    Stream #0:0 -> #0:0 (mpeg2video (native) -> mpeg2video (native))
    Stream #0:1 -> #0:1 (copy)
  Press [q] to stop, [?] for help
  [swscaler @ 0x3ad3bc0] Warning: data is not aligned! This can lead to a speed 
loss
  Output #0, vob, to 'TEMP-crop-scale.mpg':
    Metadata:
      encoder         : Lavf58.35.104
      Stream #0:0: Video: mpeg2video (Main), yuv420p, 720x425 [SAR 374:351 DAR 
352:195], q=2-31, 16384 kb/s, 25 fps, 90k tbn, 25 tbc
      Metadata:
        encoder         : Lavc58.66.101 mpeg2video
      Side data:
        cpb: bitrate max/min/avg: 30000000/0/16384000 buffer size: 4096000 
vbv_delay: N/A
      Stream #0:1: Audio: ac3, 48000 Hz, stereo, fltp, 224 kb/s
  [mpeg @ 0x397b3c0] New subtitle stream 0:2 at pos:6678542 and 
DTS:20.2873sbits/s speed=16.3x
  [mpeg @ 0x397b3c0] New subtitle stream 0:3 at pos:7571470 and DTS:22.5673s
  frame= 1500 fps=376 q=2.0 Lsize=   32602kB time=00:00:59.96 
bitrate=4453.6kbits/s speed=  15x
  video:30550kB audio:1641kB subtitle:0kB other streams:0kB global headers:0kB 
muxing overhead: 1.278884%

  $ ffmpeg -hide_banner -i TEMP-crop-scale.mpg
  Input #0, mpeg, from 'TEMP-crop-scale.mpg':
    Duration: 00:01:00.00, start: 0.540000, bitrate: 4451 kb/s
      Stream #0:0[0x1e0]: Video: mpeg2video (Main), yuv420p(tv, progressive), 
720x425 [SAR 85:81 DAR 16:9], 25 fps, 25 tbr, 90k tbn, 50 tbc
      Stream #0:1[0x80]: Audio: ac3, 48000 Hz, stereo, fltp, 224 kb/s
  At least one output file must be specified


Crop to "cropdetect" size (704:416:2:82), scale to 720x-1 and pad top/bottom to 
720x480
This is compressed horizontally (via ffplay) compared to original

  $ ffmpeg -i TEMP-original.vob -codec:v mpeg2video -b:v 16384k -bufsize 4096k 
-maxrate 30000k -codec:a copy -vf 
crop=704:416:2:82,scale=720:-1,pad=720:480:0:27 -t 60 -f vob 
TEMP-crop-scale-pad.mpg
  ffmpeg version N-96491-g4b4bcb126c Copyright (c) 2000-2020 the FFmpeg 
developers
    built with gcc 9 (GCC)
    configuration: --prefix=/usr/local/ffmpeg-master-20200125 --enable-gpl 
--enable-version3 --enable-nonfree --enable-static --disable-shared 
--disable-debug --enable-libass --enable-libfdk-aac --enable-libfreetype 
--enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis 
--enable-libvpx --enable-libx264 --enable-libx265 --enable-openssl 
--enable-libbluray --enable-libcdio
    libavutil      56. 38.100 / 56. 38.100
    libavcodec     58. 66.101 / 58. 66.101
    libavformat    58. 35.104 / 58. 35.104
    libavdevice    58.  9.103 / 58.  9.103
    libavfilter     7. 71.100 /  7. 71.100
    libswscale      5.  6.100 /  5.  6.100
    libswresample   3.  6.100 /  3.  6.100
    libpostproc    55.  6.100 / 55.  6.100
  Input #0, mpeg, from 'TEMP-original.vob':
    Duration: 01:24:52.03, start: 0.287267, bitrate: 5841 kb/s
      Stream #0:0[0x1e0]: Video: mpeg2video (Main), yuv420p(tv, top first), 
720x576 [SAR 16:15 DAR 4:3], 25 fps, 25 tbr, 90k tbn, 50 tbc
      Stream #0:1[0x80]: Audio: ac3, 48000 Hz, stereo, fltp, 224 kb/s
  Stream mapping:
    Stream #0:0 -> #0:0 (mpeg2video (native) -> mpeg2video (native))
    Stream #0:1 -> #0:1 (copy)
  Press [q] to stop, [?] for help
  [swscaler @ 0x254fbc0] Warning: data is not aligned! This can lead to a speed 
loss
  Output #0, vob, to 'TEMP-crop-scale-pad.mpg':
    Metadata:
      encoder         : Lavf58.35.104
      Stream #0:0: Video: mpeg2video (Main), yuv420p, 720x480 [SAR 374:351 DAR 
187:117], q=2-31, 16384 kb/s, 25 fps, 90k tbn, 25 tbc
      Metadata:
        encoder         : Lavc58.66.101 mpeg2video
      Side data:
        cpb: bitrate max/min/avg: 30000000/0/16384000 buffer size: 4096000 
vbv_delay: N/A
      Stream #0:1: Audio: ac3, 48000 Hz, stereo, fltp, 224 kb/s
  [mpeg @ 0x23f73c0] New subtitle stream 0:2 at pos:6678542 and 
DTS:20.2873sbits/s speed=16.3x
  [mpeg @ 0x23f73c0] New subtitle stream 0:3 at pos:7571470 and DTS:22.5673s
  frame= 1500 fps=369 q=2.0 Lsize=   32856kB time=00:00:59.96 
bitrate=4488.3kbits/s speed=14.7x
  video:30800kB audio:1641kB subtitle:0kB other streams:0kB global headers:0kB 
muxing overhead: 1.280809%

  $ ffmpeg -hide_banner -i TEMP-crop-scale-pad.mpg
  Input #0, mpeg, from 'TEMP-crop-scale-pad.mpg':
    Duration: 00:01:00.00, start: 0.540000, bitrate: 4485 kb/s
      Stream #0:0[0x1e0]: Video: mpeg2video (Main), yuv420p(tv, progressive), 
720x480 [SAR 1:1 DAR 3:2], 25 fps, 25 tbr, 90k tbn, 50 tbc
      Stream #0:1[0x80]: Audio: ac3, 48000 Hz, stereo, fltp, 224 kb/s
  At least one output file must be specified
_______________________________________________
ffmpeg-user mailing list
[email protected]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[email protected] with subject "unsubscribe".

Reply via email to