Opened 5 years ago

Closed 5 years ago

#3946 closed defect (needs_more_info)

ffmpeg does not set level-conformant refs with libx264

Reported by: francois.visagie@gmail.com Owned by:
Priority: normal Component: undetermined
Version: unspecified Keywords: libx264 refs
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:

There are three aspects to this problem:

  1. ffmpeg never sets refs to anything other than 16, even when '-level x.y' or '-x264opts level=x.y' is used
  2. No warning message is issued for the majority of cases where the default of 16 refs exceeds the Max DPB for the level
  3. The option '-level' is undocumented

How to reproduce:

ffmpeg -i _640.360.25.avi -preset veryslow outputdefault.mp4
ffmpeg version N-65557-ga8592db Copyright (c) 2000-2014 the FFmpeg developers
  built on Aug 12 2014 22:01:55 with gcc 4.8.3 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enab
le-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-lib
modplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinge
r --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis
 --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-decklink --enable-zlib
  libavutil      54.  1.100 / 54.  1.100
  libavcodec     56.  0.100 / 56.  0.100
  libavformat    56.  0.100 / 56.  0.100
  libavdevice    56.  0.100 / 56.  0.100
  libavfilter     5.  0.100 /  5.  0.100
  libswscale      3.  0.100 /  3.  0.100
  libswresample   1.  0.100 /  1.  0.100
  libpostproc    53.  0.100 / 53.  0.100
Guessed Channel Layout for  Input Stream #0.1 : stereo
Input #0, avi, from '_640.360.25.avi':
  Duration: 00:00:10.00, start: 0.000000, bitrate: 7561 kb/s
    Stream #0:0: Video: mpeg4 (Advanced Simple Profile) (XVID / 0x44495658), yuv420p, 640x360 [SAR 1:1 DAR 16:9], 6031 kb/s, 25 fps, 25 tbr, 25 tbn, 25 tbc
    Stream #0:1: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 48000 Hz, 2 channels, s16, 1536 kb/s
[libx264 @ 0420f380] using SAR=1/1
[libx264 @ 0420f380] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 @ 0420f380] profile High, level 3.1
[libx264 @ 0420f380] 264 - core 142 r2453 ea0ca51 - H.264/MPEG-4 AVC codec - Copyleft 2003-2014 - http://www.videolan.org/x264.html - options: cabac=1 ref=16 de
block=1:0:0 analyse=0x3:0x133 me=umh subme=10 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=24 chroma_me=1 trellis=2 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 ch
roma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=8 b_pyramid=2 b_adapt=
2 b_bias=0 direct=3 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=60 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmi
n=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'outputdefault.mp4':
  Metadata:
    encoder         : Lavf56.0.100
    Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 640x360 [SAR 1:1 DAR 16:9], q=-1--1, 25 fps, 12800 tbn, 25 tbc
    Metadata:
      encoder         : Lavc56.0.100 libx264
    Stream #0:1: Audio: aac (libvo_aacenc) ([64][0][0][0] / 0x0040), 48000 Hz, stereo, s16, 128 kb/s
    Metadata:
      encoder         : Lavc56.0.100 libvo_aacenc
Stream mapping:
  Stream #0:0 -> #0:0 (mpeg4 (native) -> h264 (libx264))
  Stream #0:1 -> #0:1 (pcm_s16le (native) -> aac (libvo_aacenc))
Press [q] to stop, [?] for help
frame=  251 fps= 15 q=-1.0 Lsize=    1184kB time=00:00:10.01 bitrate= 968.6kbits/s dup=1 drop=0
video:1019kB audio:157kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.723548%
[libx264 @ 0420f380] frame I:2     Avg QP:25.09  size: 36162
[libx264 @ 0420f380] frame P:60    Avg QP:24.47  size: 12750
[libx264 @ 0420f380] frame B:189   Avg QP:31.31  size:  1085
[libx264 @ 0420f380] consecutive B-frames:  0.8%  6.4% 12.0% 33.5% 13.9% 33.5%  0.0%  0.0%  0.0%
[libx264 @ 0420f380] mb I  I16..4:  4.0% 77.1% 18.9%
[libx264 @ 0420f380] mb P  I16..4:  0.4%  1.3%  0.4%  P16..4: 36.6% 20.6% 30.7%  3.7%  1.5%    skip: 4.8%
[libx264 @ 0420f380] mb B  I16..4:  0.0%  0.0%  0.0%  B16..8: 47.7%  4.8%  1.7%  direct: 1.3%  skip:44.4%  L0:41.8% L1:40.5% BI:17.7%
[libx264 @ 0420f380] 8x8 transform intra:70.9% inter:53.0%
[libx264 @ 0420f380] direct mvs  spatial:97.4% temporal:2.6%
[libx264 @ 0420f380] coded y,uvDC,uvAC intra: 81.8% 78.8% 40.8% inter: 14.5% 11.3% 2.0%
[libx264 @ 0420f380] i16 v,h,dc,p: 41% 17% 28% 14%
[libx264 @ 0420f380] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 15% 10% 18%  8% 10% 10%  9%  9% 11%
[libx264 @ 0420f380] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 16%  6%  6% 10% 13% 13% 12% 12% 13%
[libx264 @ 0420f380] i8c dc,h,v,p: 28% 28% 31% 13%
[libx264 @ 0420f380] Weighted P-Frames: Y:18.3% UV:10.0%
[libx264 @ 0420f380] ref P L0: 58.5% 17.3%  8.4%  4.3%  1.8%  2.6%  1.3%  1.3%  0.7%  0.9%  0.5%  0.5%  0.5%  0.5%  0.4%  0.5%
[libx264 @ 0420f380] ref B L0: 91.8%  3.9%  2.0%  0.5%  0.5%  0.3%  0.2%  0.1%  0.2%  0.1%  0.1%  0.1%  0.1%  0.1%  0.0%
[libx264 @ 0420f380] ref B L1: 95.5%  4.5%
[libx264 @ 0420f380] kb/s:830.51

Result: refs = 16

ffmpeg -i _640.360.25.avi -preset veryslow -level 3.1 output-level3.1.mp4
ffmpeg version N-65557-ga8592db Copyright (c) 2000-2014 the FFmpeg developers
  built on Aug 12 2014 22:01:55 with gcc 4.8.3 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enab
le-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-lib
modplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinge
r --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis
 --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-decklink --enable-zlib
  libavutil      54.  1.100 / 54.  1.100
  libavcodec     56.  0.100 / 56.  0.100
  libavformat    56.  0.100 / 56.  0.100
  libavdevice    56.  0.100 / 56.  0.100
  libavfilter     5.  0.100 /  5.  0.100
  libswscale      3.  0.100 /  3.  0.100
  libswresample   1.  0.100 /  1.  0.100
  libpostproc    53.  0.100 / 53.  0.100
Guessed Channel Layout for  Input Stream #0.1 : stereo
Input #0, avi, from '_640.360.25.avi':
  Duration: 00:00:10.00, start: 0.000000, bitrate: 7561 kb/s
    Stream #0:0: Video: mpeg4 (Advanced Simple Profile) (XVID / 0x44495658), yuv420p, 640x360 [SAR 1:1 DAR 16:9], 6031 kb/s, 25 fps, 25 tbr, 25 tbn, 25 tbc
    Stream #0:1: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 48000 Hz, 2 channels, s16, 1536 kb/s
[libx264 @ 03edf7e0] using SAR=1/1
[libx264 @ 03edf7e0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 @ 03edf7e0] profile High, level 3.1
[libx264 @ 03edf7e0] 264 - core 142 r2453 ea0ca51 - H.264/MPEG-4 AVC codec - Copyleft 2003-2014 - http://www.videolan.org/x264.html - options: cabac=1 ref=16 de
block=1:0:0 analyse=0x3:0x133 me=umh subme=10 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=24 chroma_me=1 trellis=2 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 ch
roma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=8 b_pyramid=2 b_adapt=
2 b_bias=0 direct=3 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=60 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmi
n=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'output-level3.1.mp4':
  Metadata:
    encoder         : Lavf56.0.100
    Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 640x360 [SAR 1:1 DAR 16:9], q=-1--1, 25 fps, 12800 tbn, 25 tbc
    Metadata:
      encoder         : Lavc56.0.100 libx264
    Stream #0:1: Audio: aac (libvo_aacenc) ([64][0][0][0] / 0x0040), 48000 Hz, stereo, s16, 128 kb/s
    Metadata:
      encoder         : Lavc56.0.100 libvo_aacenc
Stream mapping:
  Stream #0:0 -> #0:0 (mpeg4 (native) -> h264 (libx264))
  Stream #0:1 -> #0:1 (pcm_s16le (native) -> aac (libvo_aacenc))
Press [q] to stop, [?] for help
frame=  251 fps= 15 q=-1.0 Lsize=    1184kB time=00:00:10.01 bitrate= 968.6kbits/s dup=1 drop=0
video:1019kB audio:157kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.723548%
[libx264 @ 03edf7e0] frame I:2     Avg QP:25.09  size: 36162
[libx264 @ 03edf7e0] frame P:60    Avg QP:24.47  size: 12750
[libx264 @ 03edf7e0] frame B:189   Avg QP:31.31  size:  1085
[libx264 @ 03edf7e0] consecutive B-frames:  0.8%  6.4% 12.0% 33.5% 13.9% 33.5%  0.0%  0.0%  0.0%
[libx264 @ 03edf7e0] mb I  I16..4:  4.0% 77.1% 18.9%
[libx264 @ 03edf7e0] mb P  I16..4:  0.4%  1.3%  0.4%  P16..4: 36.6% 20.6% 30.7%  3.7%  1.5%    skip: 4.8%
[libx264 @ 03edf7e0] mb B  I16..4:  0.0%  0.0%  0.0%  B16..8: 47.7%  4.8%  1.7%  direct: 1.3%  skip:44.4%  L0:41.8% L1:40.5% BI:17.7%
[libx264 @ 03edf7e0] 8x8 transform intra:70.9% inter:53.0%
[libx264 @ 03edf7e0] direct mvs  spatial:97.4% temporal:2.6%
[libx264 @ 03edf7e0] coded y,uvDC,uvAC intra: 81.8% 78.8% 40.8% inter: 14.5% 11.3% 2.0%
[libx264 @ 03edf7e0] i16 v,h,dc,p: 41% 17% 28% 14%
[libx264 @ 03edf7e0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 15% 10% 18%  8% 10% 10%  9%  9% 11%
[libx264 @ 03edf7e0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 16%  6%  6% 10% 13% 13% 12% 12% 13%
[libx264 @ 03edf7e0] i8c dc,h,v,p: 28% 28% 31% 13%
[libx264 @ 03edf7e0] Weighted P-Frames: Y:18.3% UV:10.0%
[libx264 @ 03edf7e0] ref P L0: 58.5% 17.3%  8.4%  4.3%  1.8%  2.6%  1.3%  1.3%  0.7%  0.9%  0.5%  0.5%  0.5%  0.5%  0.4%  0.5%
[libx264 @ 03edf7e0] ref B L0: 91.8%  3.9%  2.0%  0.5%  0.5%  0.3%  0.2%  0.1%  0.2%  0.1%  0.1%  0.1%  0.1%  0.1%  0.0%
[libx264 @ 03edf7e0] ref B L1: 95.5%  4.5%
[libx264 @ 03edf7e0] kb/s:830.51

Result: refs = 16

ffmpeg -i _640.360.25.avi -preset veryslow -x264opts level=3.1 output--level3.1.mp4
ffmpeg version N-65557-ga8592db Copyright (c) 2000-2014 the FFmpeg developers
  built on Aug 12 2014 22:01:55 with gcc 4.8.3 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enab
le-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-lib
modplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinge
r --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis
 --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-decklink --enable-zlib
  libavutil      54.  1.100 / 54.  1.100
  libavcodec     56.  0.100 / 56.  0.100
  libavformat    56.  0.100 / 56.  0.100
  libavdevice    56.  0.100 / 56.  0.100
  libavfilter     5.  0.100 /  5.  0.100
  libswscale      3.  0.100 /  3.  0.100
  libswresample   1.  0.100 /  1.  0.100
  libpostproc    53.  0.100 / 53.  0.100
Guessed Channel Layout for  Input Stream #0.1 : stereo
Input #0, avi, from '_640.360.25.avi':
  Duration: 00:00:10.00, start: 0.000000, bitrate: 7561 kb/s
    Stream #0:0: Video: mpeg4 (Advanced Simple Profile) (XVID / 0x44495658), yuv420p, 640x360 [SAR 1:1 DAR 16:9], 6031 kb/s, 25 fps, 25 tbr, 25 tbn, 25 tbc
    Stream #0:1: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 48000 Hz, 2 channels, s16, 1536 kb/s
[libx264 @ 03fd2560] using SAR=1/1
[libx264 @ 03fd2560] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 @ 03fd2560] profile High, level 3.1
[libx264 @ 03fd2560] 264 - core 142 r2453 ea0ca51 - H.264/MPEG-4 AVC codec - Copyleft 2003-2014 - http://www.videolan.org/x264.html - options: cabac=1 ref=16 de
block=1:0:0 analyse=0x3:0x133 me=umh subme=10 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=24 chroma_me=1 trellis=2 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 ch
roma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=8 b_pyramid=2 b_adapt=
2 b_bias=0 direct=3 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=60 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmi
n=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'output--level3.1.mp4':
  Metadata:
    encoder         : Lavf56.0.100
    Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 640x360 [SAR 1:1 DAR 16:9], q=-1--1, 25 fps, 12800 tbn, 25 tbc
    Metadata:
      encoder         : Lavc56.0.100 libx264
    Stream #0:1: Audio: aac (libvo_aacenc) ([64][0][0][0] / 0x0040), 48000 Hz, stereo, s16, 128 kb/s
    Metadata:
      encoder         : Lavc56.0.100 libvo_aacenc
Stream mapping:
  Stream #0:0 -> #0:0 (mpeg4 (native) -> h264 (libx264))
  Stream #0:1 -> #0:1 (pcm_s16le (native) -> aac (libvo_aacenc))
Press [q] to stop, [?] for help
frame=  251 fps= 15 q=-1.0 Lsize=    1184kB time=00:00:10.01 bitrate= 968.6kbits/s dup=1 drop=0
video:1019kB audio:157kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.723548%
[libx264 @ 03fd2560] frame I:2     Avg QP:25.09  size: 36162
[libx264 @ 03fd2560] frame P:60    Avg QP:24.47  size: 12750
[libx264 @ 03fd2560] frame B:189   Avg QP:31.31  size:  1085
[libx264 @ 03fd2560] consecutive B-frames:  0.8%  6.4% 12.0% 33.5% 13.9% 33.5%  0.0%  0.0%  0.0%
[libx264 @ 03fd2560] mb I  I16..4:  4.0% 77.1% 18.9%
[libx264 @ 03fd2560] mb P  I16..4:  0.4%  1.3%  0.4%  P16..4: 36.6% 20.6% 30.7%  3.7%  1.5%    skip: 4.8%
[libx264 @ 03fd2560] mb B  I16..4:  0.0%  0.0%  0.0%  B16..8: 47.7%  4.8%  1.7%  direct: 1.3%  skip:44.4%  L0:41.8% L1:40.5% BI:17.7%
[libx264 @ 03fd2560] 8x8 transform intra:70.9% inter:53.0%
[libx264 @ 03fd2560] direct mvs  spatial:97.4% temporal:2.6%
[libx264 @ 03fd2560] coded y,uvDC,uvAC intra: 81.8% 78.8% 40.8% inter: 14.5% 11.3% 2.0%
[libx264 @ 03fd2560] i16 v,h,dc,p: 41% 17% 28% 14%
[libx264 @ 03fd2560] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 15% 10% 18%  8% 10% 10%  9%  9% 11%
[libx264 @ 03fd2560] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 16%  6%  6% 10% 13% 13% 12% 12% 13%
[libx264 @ 03fd2560] i8c dc,h,v,p: 28% 28% 31% 13%
[libx264 @ 03fd2560] Weighted P-Frames: Y:18.3% UV:10.0%
[libx264 @ 03fd2560] ref P L0: 58.5% 17.3%  8.4%  4.3%  1.8%  2.6%  1.3%  1.3%  0.7%  0.9%  0.5%  0.5%  0.5%  0.5%  0.4%  0.5%
[libx264 @ 03fd2560] ref B L0: 91.8%  3.9%  2.0%  0.5%  0.5%  0.3%  0.2%  0.1%  0.2%  0.1%  0.1%  0.1%  0.1%  0.1%  0.0%
[libx264 @ 03fd2560] ref B L1: 95.5%  4.5%
[libx264 @ 03fd2560] kb/s:830.51

Result: refs = 16

This seems related to - and is perhaps a regression since - https://trac.ffmpeg.org/ticket/3307.

Change History (1)

comment:1 Changed 5 years ago by francois.visagie@gmail.com

  • Resolution set to needs_more_info
  • Status changed from new to closed

These examples aren't very informative. I'll post better ones in a new ticket.

Note: See TracTickets for help on using tickets.