Opened 12 years ago

Last modified 4 years ago

#1618 open defect

Padding to odd/uneven size fails

Reported by: agowad Owned by:
Priority: normal Component: avfilter
Version: git-master Keywords: pad
Cc: Blocked By:
Blocking: Reproduced by developer: yes
Analyzed by developer: no

Description (last modified by Carl Eugen Hoyos)

### WHAT
I am try resize (scale + pad) and convert a video file to mp4 format and defined size.

### PROBLEM
When padding to odd width I face problems. Strangely, when I use even numbers then it works.

### COMMAND LINES (for two files)

  1. File "Duracell10sec_CutdowulydCDCD.wmv"

A.1 Resizing to 425x300

  • COMMAND LINE:
    ffmpeg.exe -i "Duracell10sec_Cutdow__ulydCDCD.wmv"  -vf "scale=427:239,pad=427:300:0:30,setdar=427:300"  -y -b:v 400k -r 49.75 -ar 44100  -acodec libmp3lame -vcodec libx264 -ac 2 "Duracell10sec_Cutdow__ulydCDCD4_TMP.mp4"
    
  • OUTPUT:
    ffmpeg version N-43206-gf857465 Copyright (c) 2000-2012 the FFmpeg developers
      built on Aug  4 2012 16:10:39 with gcc 4.7.1 (GCC)
      configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-runtime-cpudetect --enable-avisynth --enable-bzlib --enable-frei0r --ena
    ble-libass --enable-libcelt --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libfreetype --enable-libgsm --enable-libmp3lame --enable-li
    bnut --enable-libopenjpeg --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libutvideo --enable-libvo-aacenc --e
    nable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib
      libavutil      51. 66.100 / 51. 66.100
      libavcodec     54. 49.100 / 54. 49.100
      libavformat    54. 22.100 / 54. 22.100
      libavdevice    54.  2.100 / 54.  2.100
      libavfilter     3.  5.102 /  3.  5.102
      libswscale      2.  1.100 /  2.  1.100
      libswresample   0. 15.100 /  0. 15.100
      libpostproc    52.  0.100 / 52.  0.100
    Guessed Channel Layout for  Input Stream #0.0 : mono
    Input #0, asf, from 'Duracell10sec_Cutdow__ulydCDCD.wmv':
      Metadata:
        WMFSDKVersion   : 10.00.00.3702
        WMFSDKNeeded    : 0.0.0.0000
        IsVBR           : 1
        VBR Peak        : 139
        Buffer Average  : 151
      Duration: 00:00:10.04, start: 0.000000, bitrate: 1864 kb/s
        Stream #0:0(dan): Audio: wmav2 (a[1][0][0] / 0x0161), 8000 Hz, mono, s16, 0 kb/s
        Stream #0:1(dan): Video: wmv3 (Main) (WMV3 / 0x33564D57), yuv420p, 1280x720, 1843 kb/s, 49.75 tbr, 1k tbn, 1k tbc
    [Parsed_pad_1 @ 01f9a760] Input area 0:30:427:269 not within the padded area 0:0:426:300 or zero-sized
    [Parsed_scale_0 @ 01fe7260] Failed to configure input pad on Parsed_pad_1
    Error opening filters!
    
  1. File "fishermans_friendCD_720_xvid.avi"

B.1 Resizing to 425x300

  • COMMAND LINE:
    ffmpeg.exe -i "fishermans_friendCD_720_xvid.avi"  -vf "scale=425:239,pad=425:300:0:30,setdar=425:300"  -y -b:v 400k -r 25 -ar 44100  -ab 128 -acodec libmp3lame -vcodec libx264 -ac 2 "fishermans_friendCD_720_xvid4_TMP.mp4"
    
  • OUTPUT:
    ffmpeg version N-43206-gf857465 Copyright (c) 2000-2012 the FFmpeg developers
      built on Aug  4 2012 16:10:39 with gcc 4.7.1 (GCC)
      configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-runtime-cpudetect --enable-avisynth --enable-bzlib --enable-frei0r --ena
    ble-libass --enable-libcelt --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libfreetype --enable-libgsm --enable-libmp3lame --enable-li
    bnut --enable-libopenjpeg --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libutvideo --enable-libvo-aacenc --e
    nable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib
      libavutil      51. 66.100 / 51. 66.100
      libavcodec     54. 49.100 / 54. 49.100
      libavformat    54. 22.100 / 54. 22.100
      libavdevice    54.  2.100 / 54.  2.100
      libavfilter     3.  5.102 /  3.  5.102
      libswscale      2.  1.100 /  2.  1.100
      libswresample   0. 15.100 /  0. 15.100
      libpostproc    52.  0.100 / 52.  0.100
    Input #0, avi, from 'fishermans_friendCD_720_xvid.avi':
      Metadata:
        encoder         : MEncoder Sherpya-SVN-r32492-4.2.5
      Duration: 00:00:09.96, start: 0.000000, bitrate: 1090 kb/s
        Stream #0:0: Video: mpeg4 (Simple Profile) (XVID / 0x44495658), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 25 tbr, 25 tbn, 25 tbc
        Stream #0:1: Audio: mp3 (U[0][0][0] / 0x0055), 44100 Hz, stereo, s16, 128 kb/s
    [Parsed_pad_1 @ 03fd59e0] Input area 0:30:425:269 not within the padded area 0:0:424:300 or zero-sized
    [Parsed_scale_0 @ 03fd5940] Failed to configure input pad on Parsed_pad_1
    Error opening filters!
    

### FILES

  1. "Duracell10sec_CutdowulydCDCD.wmv"
  • OUTPUT:
    ffmpeg version N-43206-gf857465 Copyright (c) 2000-2012 the FFmpeg developers
      built on Aug  4 2012 16:10:39 with gcc 4.7.1 (GCC)
      configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-runtime-cpudetect --enable-avisynth --enable-bzlib --enable-frei0r --ena
    ble-libass --enable-libcelt --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libfreetype --enable-libgsm --enable-libmp3lame --enable-li
    bnut --enable-libopenjpeg --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libutvideo --enable-libvo-aacenc --e
    nable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib
      libavutil      51. 66.100 / 51. 66.100
      libavcodec     54. 49.100 / 54. 49.100
      libavformat    54. 22.100 / 54. 22.100
      libavdevice    54.  2.100 / 54.  2.100
      libavfilter     3.  5.102 /  3.  5.102
      libswscale      2.  1.100 /  2.  1.100
      libswresample   0. 15.100 /  0. 15.100
      libpostproc    52.  0.100 / 52.  0.100
    [asf @ 01fbc400] Format asf probed with size=2048 and score=100
    [asf @ 01fbc400] gpos mismatch our pos=24, end=26
    [asf @ 01fbc400] gpos mismatch our pos=24, end=3622
    [asf @ 01fbc400] gpos mismatch our pos=24, end=38
    [asf @ 01fbc400] Unsupported value type 1 in tag ASFLeakyBucketPairs.
    [asf @ 01fbc400] gpos mismatch our pos=24, end=252
    [asf @ 01fbc400] gpos mismatch our pos=24, end=38
    [asf @ 01fbc400] File position before avformat_find_stream_info() is 5300
    [asf @ 01fbc400] parser not found for codec wmav2, packets or times may be invalid.
    [wmv3 @ 01fbd720] Header: 4DC11A01
    [wmv3 @ 01fbd720] Profile 1:
    frmrtq_postproc=6, bitrtq_postproc=28
    LoopFilter=0, MultiRes=0, FastUVMC=0, Extended MV=0
    Rangered=0, VSTransform=1, Overlap=1, SyncMarker=0
    DQuant=1, Quantizer mode=0, Max B frames=0
    [asf @ 01fbc400] parser not found for codec wmav2, packets or times may be invalid.
    [asf @ 01fbc400] All info found
    rfps: 24.583333 0.019493
        Last message repeated 1 times
    rfps: 24.666667 0.010206
        Last message repeated 1 times
    rfps: 24.750000 0.003909
        Last message repeated 1 times
    rfps: 24.833333 0.000600
        Last message repeated 1 times
    rfps: 24.916667 0.000281
    rfps: 25.000000 0.002950
    rfps: 25.083333 0.008607
        Last message repeated 1 times
    rfps: 25.166667 0.017254
        Last message repeated 1 times
    rfps: 49.500000 0.015636
        Last message repeated 1 times
    rfps: 49.583333 0.007524
        Last message repeated 1 times
    rfps: 49.666667 0.002402
        Last message repeated 1 times
    rfps: 49.750000 0.000268
        Last message repeated 1 times
    rfps: 49.833333 0.001122
    rfps: 49.916667 0.004966
    rfps: 50.000000 0.011798
    [asf @ 01fbc400] File position after avformat_find_stream_info() is 251519
    Guessed Channel Layout for  Input Stream #0.0 : mono
    Input #0, asf, from 'Duracell10sec_Cutdow__ulydCDCD.wmv':
      Metadata:
        WMFSDKVersion   : 10.00.00.3702
        WMFSDKNeeded    : 0.0.0.0000
        IsVBR           : 1
        VBR Peak        : 139
        Buffer Average  : 151
      Duration: 00:00:10.04, start: 0.000000, bitrate: 1864 kb/s
        Stream #0:0(dan), 18, 1/1000: Audio: wmav2 (a[1][0][0] / 0x0161), 8000 Hz, mono, s16, 0 kb/s
        Stream #0:1(dan), 41, 1/1000: Video: wmv3 (Main) (WMV3 / 0x33564D57), yuv420p, 1280x720, 1/1000, 1843 kb/s, 49.75 tbr, 1k tbn, 1k tbc
    At least one output file must be specified
    [AVIOContext @ 01fb14e0] Statistics: 262144 bytes read, 0 seeks
    
  1. "fishermans_friendCD_720_xvid.avi"
  • OUTPUT:
    ffmpeg version N-43206-gf857465 Copyright (c) 2000-2012 the FFmpeg developers
      built on Aug  4 2012 16:10:39 with gcc 4.7.1 (GCC)
      configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-runtime-cpudetect --enable-avisynth --enable-bzlib --enable-frei0r --ena
    ble-libass --enable-libcelt --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libfreetype --enable-libgsm --enable-libmp3lame --enable-li
    bnut --enable-libopenjpeg --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libutvideo --enable-libvo-aacenc --e
    nable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib
      libavutil      51. 66.100 / 51. 66.100
      libavcodec     54. 49.100 / 54. 49.100
      libavformat    54. 22.100 / 54. 22.100
      libavdevice    54.  2.100 / 54.  2.100
      libavfilter     3.  5.102 /  3.  5.102
      libswscale      2.  1.100 /  2.  1.100
      libswresample   0. 15.100 /  0. 15.100
      libpostproc    52.  0.100 / 52.  0.100
    [avi @ 0235c400] Format avi probed with size=2048 and score=100
    [avi @ 02351560] use odml:1
    st:1 removing common factor 36 from timebase
    [avi @ 0235c400] File position before avformat_find_stream_info() is 4108
    [avi @ 0235c400] All info found
    [avi @ 0235c400] File position after avformat_find_stream_info() is 22706
    Input #0, avi, from 'fishermans_friendCD_720_xvid.avi':
      Metadata:
        encoder         : MEncoder Sherpya-SVN-r32492-4.2.5
      Duration: 00:00:09.96, start: 0.000000, bitrate: 1090 kb/s
        Stream #0:0, 1, 1/25: Video: mpeg4 (Simple Profile) (XVID / 0x44495658), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 1/25, 25 tbr, 25 tbn, 25 tbc
        Stream #0:1, 20, 32/1225: Audio: mp3 (U[0][0][0] / 0x0055), 44100 Hz, stereo, s16, 128 kb/s
    At least one output file must be specified
    [AVIOContext @ 023514c0] Statistics: 184008 bytes read, 7 seeks
    

Attachments (2)

Duracell10sec_Cutdow__ulydCDCD.wmv (2.2 MB ) - added by agowad 12 years ago.
File that fails when padding to uneven width
fishermans_friendCD_720_xvid.avi (1.3 MB ) - added by agowad 12 years ago.
File that fails when padding to uneven width

Change History (10)

by agowad, 12 years ago

File that fails when padding to uneven width

by agowad, 12 years ago

File that fails when padding to uneven width

comment:1 by Carl Eugen Hoyos, 12 years ago

Component: FFmpegundetermined
Description: modified (diff)
Version: unspecifiedgit-master

comment:2 by agowad, 12 years ago

The same error can be generated by shorter version of the command.

  • COMMAND LINE:
ffmpeg.exe -i "Duracell10sec_Cutdow__ulydCDCD.wmv"  -vf "scale=427:239,pad=427:300:0:30,setdar=427:300" "Duracell10sec_Cutdow__ulydCDCD4_TMP.mp4"

comment:3 by Carl Eugen Hoyos, 12 years ago

Component: undeterminedavfilter
Keywords: padding removed
Reproduced by developer: set
Status: newopen
Summary: Scaling and padding to odd/uneven size failsPadding to odd/uneven size fails

videofilter pad does not accept odd size values, I don't think this is documented.

$ ffmpeg -f lavfi -i rgbtestsrc -vf scale=319:240,pad=319:240 out.avi
ffmpeg version N-43418-g633b90c Copyright (c) 2000-2012 the FFmpeg developers
  built on Aug 10 2012 11:20:41 with gcc 4.3.2 (GCC)
  configuration: --cc=/usr/local/gcc-4.3.2/bin/gcc --enable-gpl --enable-libopenjpeg --enable-libvorbis --enable-libspeex --enable-libmp3lame --enable-libtheora --extra-ldflags=-lm --enable-libvpx --enable-libxavs --enable-x11grab --enable-libass --enable-nonfree --enable-libfaac --enable-libopus --enable-libfdk-aac
  libavutil      51. 67.100 / 51. 67.100
  libavcodec     54. 51.100 / 54. 51.100
  libavformat    54. 22.104 / 54. 22.104
  libavdevice    54.  2.100 / 54.  2.100
  libavfilter     3.  7.100 /  3.  7.100
  libswscale      2.  1.101 /  2.  1.101
  libswresample   0. 15.100 /  0. 15.100
  libpostproc    52.  0.100 / 52.  0.100
[lavfi @ 0x9100540] Estimating duration from bitrate, this may be inaccurate
Input #0, lavfi, from 'rgbtestsrc':
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: rawvideo (RGBA / 0x41424752), rgba, 320x240 [SAR 1:1 DAR 4:3], 25 tbr, 25 tbn, 25 tbc
[Parsed_pad_1 @ 0x90fe2e0] Input area 0:0:319:240 not within the padded area 0:0:318:240 or zero-sized
[Parsed_scale_0 @ 0x90fdd80] Failed to configure input pad on Parsed_pad_1
Error opening filters!

comment:4 by Elon Musk, 11 years ago

I do not see how padding for subsampled formats could work at all. In non trivial cases it needs chroma interpolation. So using yuv444p or rgb formats should be workaround.

in reply to:  4 comment:5 by Carl Eugen Hoyos, 11 years ago

Replying to richardpl:

I do not see how padding for subsampled formats could work at all. In non trivial cases it needs chroma interpolation. So using yuv444p or rgb formats should be workaround.

The scale filter supports odd sizes for subsampled formats, why shouldn't the pad filter allow the same?

comment:6 by Elon Musk, 11 years ago

Your reasoning is flawed. Scale filter does not scale by itself - it use libswscale.

Non trivial padding - for example padding for 1 pixel left/above for subsampled format.

in reply to:  6 comment:7 by Carl Eugen Hoyos, 11 years ago

Replying to richardpl:

Your reasoning is flawed. Scale filter does not scale by itself - it use libswscale.

How is that related?

Non trivial padding - for example padding for 1 pixel left/above for subsampled format.

I understand that it would not (easily) work for left/top padding but that was not requested in this ticket, I am simply wondering why it shouldn't work for right/bottom padding.
Note that the original request was actually that pad should not fail if input size == output size.

comment:8 by Ivan Middleton, 4 years ago

I propose to fix this bug by having the pad filter round the output width and height up instead of down.

See my message to the devel list for more details and a patch:

https://ffmpeg.org/pipermail/ffmpeg-devel/2020-January/256384.html

Note: See TracTickets for help on using tickets.