Opened 3 years ago

Last modified 3 years ago

#9012 new defect

specified frame type is not compatible with max B-frames

Reported by: malaterre Owned by:
Priority: normal Component: ffmpeg
Version: git-master Keywords:
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:
How to reproduce:

$ ./ffmpeg -y -i ffmpeg_crash.mkv -c:v libx264 -b:v 597k -pass 1 -an -f null /dev/null && \
./ffmpeg -y -i ffmpeg_crash.mkv -c:v libx264 -b:v 597k -pass 2 -c:a aac -b:a 123k test.mp4
[...]
[libx264 @ 0x65f7240] 2nd pass has more frames than 1st pass (1392)= 703.3kbits/s dup=2 drop=0 speed=13.4x    
[libx264 @ 0x65f7240] continuing anyway, at constant QP=12
[libx264 @ 0x65f7240] disabling adaptive B-frames
[libx264 @ 0x65f7240] specified frame type is not compatible with max B-frames
zsh: segmentation fault  ./ffmpeg -y -i ffmpeg_crash.mkv -c:v libx264 -b:v 597k -pass 2 -c:a aac -b:a 

Using:

$ ./ffmpeg -version 
ffmpeg version N-54874-ga1553b0cfb-static https://johnvansickle.com/ffmpeg/  Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 8 (Debian 8.3.0-6)
configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio --cc=gcc --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gmp --enable-libgme --enable-gray --enable-libaom --enable-libfribidi --enable-libass --enable-libvmaf --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librubberband --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libvorbis --enable-libopus --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libdav1d --enable-libxvid --enable-libzvbi --enable-libzimg
libavutil      56. 60.100 / 56. 60.100
libavcodec     58.112.101 / 58.112.101
libavformat    58. 64.100 / 58. 64.100
libavdevice    58. 11.102 / 58. 11.102
libavfilter     7. 88.102 /  7. 88.102
libswscale      5.  8.100 /  5.  8.100
libswresample   3.  8.100 /  3.  8.100
libpostproc    55.  8.100 / 55.  8.100

Change History (4)

comment:2 by malaterre, 3 years ago

Using:

$ ffmpeg -i ffmpeg_crash.mkv -codec copy -bsf:v mpeg4_unpack_bframes ffmpeg_crash_unpack.mkv

does not help.

comment:3 by malaterre, 3 years ago

Original crash was done using:

 ffmpeg -y -i original.mkv -c:v libx264 -b:v 1325k -pass 1 -an -f null /dev/null && \
ffmpeg -i original.mkv -c:v libx264 -b:v 1325k -pass 2 -c:a aac -b:a 128k test.mp4

Where:

 mediainfo original.mkv 
General
Unique ID                                : 147936370036470747729475983702073706467 (0x6F4B822C83673DFF5260B2C6B79E87E3)
Complete name                            : original.mkv
Format                                   : Matroska
Format version                           : Version 4
File size                                : 674 MiB
Duration                                 : 1 h 4 min
Overall bit rate mode                    : Variable
Overall bit rate                         : 1 453 kb/s
Writing application                      : Lavf58.20.100
Writing library                          : Lavf58.20.100
ErrorDetectionType                       : Per level 1

Video
ID                                       : 1
Format                                   : MPEG-4 Visual
Format profile                           : Advanced Simple@L5
Format settings                          : BVOP1
Format settings, BVOP                    : 1
Format settings, QPel                    : No
Format settings, GMC                     : No warppoints
Format settings, Matrix                  : Default (H.263)
Muxing mode                              : Packed bitstream
Codec ID                                 : V_MPEG4/ISO/ASP
Codec ID/Info                            : Advanced Simple Profile
Duration                                 : 1 h 4 min
Bit rate                                 : 1 301 kb/s
Width                                    : 576 pixels
Height                                   : 320 pixels
Display aspect ratio                     : 16:9
Frame rate mode                          : Constant
Frame rate                               : 25.000 FPS
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Compression mode                         : Lossy
Bits/(Pixel*Frame)                       : 0.282
Stream size                              : 604 MiB (90%)
Writing library                          : XviD 1.0.1 (UTC 2004-06-05)
Default                                  : Yes
Forced                                   : No

Audio
ID                                       : 2
Format                                   : MPEG Audio
Format version                           : Version 1
Format profile                           : Layer 3
Format settings                          : Joint stereo / MS Stereo
Codec ID                                 : A_MPEG/L3
Codec ID/Hint                            : MP3
Duration                                 : 1 h 4 min
Bit rate mode                            : Variable
Bit rate                                 : 123 kb/s
Channel(s)                               : 2 channels
Sampling rate                            : 48.0 kHz
Frame rate                               : 41.667 FPS (1152 SPF)
Compression mode                         : Lossy
Delay relative to video                  : -51 ms
Stream size                              : 57.2 MiB (8%)
Writing library                          : Lavf
Default                                  : No
Forced                                   : No

comment:4 by malaterre, 3 years ago

valgrind reveals:

==7400== Invalid read of size 4=    4864kB time=00:00:55.65 bitrate= 715.9kbits/s dup=2 drop=0 speed=0.0468x    
==7400==    at 0xC9CFEAF: x264_8_macroblock_tree_read (ratecontrol.c:545)
==7400==    by 0xC9F82C4: x264_8_encoder_encode (encoder.c:3299)
==7400==    by 0xCA884AB: ??? (in /usr/lib/x86_64-linux-gnu/libx264.so.155)
==7400==    by 0xC977BB0: x264_encoder_encode (api.c:170)
==7400==    by 0x5310494: X264_frame (libx264.c:342)
==7400==    by 0x50D16B1: avcodec_encode_video2 (encode.c:296)
==7400==    by 0x50D1ABC: do_encode (encode.c:365)
==7400==    by 0x50D1C51: avcodec_send_frame (encode.c:414)
==7400==    by 0x12E9DD: do_video_out (ffmpeg.c:1293)
==7400==    by 0x1320D5: reap_filters (ffmpeg.c:1511)
==7400==    by 0x136C23: transcode_step (ffmpeg.c:4653)
==7400==    by 0x136C23: transcode (ffmpeg.c:4697)
==7400==    by 0x1147CD: main (ffmpeg.c:4904)
==7400==  Address 0x196efcc8 is 8 bytes after a block of size 278,400 alloc'd
==7400==    at 0x4838123: memalign (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==7400==    by 0xC975909: x264_malloc (base.c:124)
==7400==    by 0xC9D181F: x264_8_ratecontrol_new (ratecontrol.c:1016)
==7400==    by 0xC9F54A5: x264_8_encoder_open (encoder.c:1701)
==7400==    by 0xC977AA5: encoder_open (api.c:95)
==7400==    by 0xCA884AB: ??? (in /usr/lib/x86_64-linux-gnu/libx264.so.155)
==7400==    by 0x4EE31C7: X264_init (libx264.c:811)
==7400==    by 0x551394F: avcodec_open2 (utils.c:947)
==7400==    by 0x130C1A: init_output_stream.constprop.19 (ffmpeg.c:3526)
==7400==    by 0x132B40: reap_filters (ffmpeg.c:1447)
==7400==    by 0x136C23: transcode_step (ffmpeg.c:4653)
==7400==    by 0x136C23: transcode (ffmpeg.c:4697)
==7400==    by 0x1147CD: main (ffmpeg.c:4904)
==7400== 
[libx264 @ 0x17ac8100] 2nd pass has more frames than 1st pass (1392)
[libx264 @ 0x17ac8100] continuing anyway, at constant QP=12
[libx264 @ 0x17ac8100] disabling adaptive B-frames
[libx264 @ 0x17ac8100] specified frame type is not compatible with max B-frames
==7400== Invalid read of size 2    4864kB time=00:00:55.65 bitrate= 715.9kbits/s dup=2 drop=0 speed=0.0466x     
==7400==    at 0xC9A54F7: weight_cost_init_luma.isra.11 (slicetype.c:82)
==7400==    by 0xC9C0C33: x264_8_weights_analyse (slicetype.c:362)
==7400==    by 0xC9C3F91: x264_8_slicetype_decide (slicetype.c:1935)
==7400==    by 0xC9FB1A5: x264_8_lookahead_get_frames (lookahead.c:238)
==7400==    by 0xC9F7957: x264_8_encoder_encode (encoder.c:3333)
==7400==    by 0xCA884AB: ??? (in /usr/lib/x86_64-linux-gnu/libx264.so.155)
==7400==    by 0xC977BB0: x264_encoder_encode (api.c:170)
==7400==    by 0x5310558: X264_frame (libx264.c:342)
==7400==    by 0x50D16B1: avcodec_encode_video2 (encode.c:296)
==7400==    by 0x50D1ABC: do_encode (encode.c:365)
==7400==    by 0x50D1C51: avcodec_send_frame (encode.c:414)
==7400==    by 0x136231: flush_encoders (ffmpeg.c:1942)
==7400==    by 0x136231: transcode (ffmpeg.c:4717)
==7400==  Address 0x0 is not stack'd, malloc'd or (recently) free'd
==7400== 
==7400== 
==7400== Process terminating with default action of signal 11 (SIGSEGV)
==7400==  Access not within mapped region at address 0x0
==7400==    at 0xC9A54F7: weight_cost_init_luma.isra.11 (slicetype.c:82)
==7400==    by 0xC9C0C33: x264_8_weights_analyse (slicetype.c:362)
==7400==    by 0xC9C3F91: x264_8_slicetype_decide (slicetype.c:1935)
==7400==    by 0xC9FB1A5: x264_8_lookahead_get_frames (lookahead.c:238)
==7400==    by 0xC9F7957: x264_8_encoder_encode (encoder.c:3333)
==7400==    by 0xCA884AB: ??? (in /usr/lib/x86_64-linux-gnu/libx264.so.155)
==7400==    by 0xC977BB0: x264_encoder_encode (api.c:170)
==7400==    by 0x5310558: X264_frame (libx264.c:342)
==7400==    by 0x50D16B1: avcodec_encode_video2 (encode.c:296)
==7400==    by 0x50D1ABC: do_encode (encode.c:365)
==7400==    by 0x50D1C51: avcodec_send_frame (encode.c:414)
==7400==    by 0x136231: flush_encoders (ffmpeg.c:1942)
==7400==    by 0x136231: transcode (ffmpeg.c:4717)
==7400==  If you believe this happened as a result of a stack
==7400==  overflow in your program's main thread (unlikely but
==7400==  possible), you can try to increase the size of the
==7400==  main thread stack using the --main-stacksize= flag.
==7400==  The main thread stack size used in this run was 8388608.
==7400== 
==7400== HEAP SUMMARY:
==7400==     in use at exit: 36,818,577 bytes in 2,882 blocks
==7400==   total heap usage: 301,652 allocs, 298,770 frees, 5,216,912,469 bytes allocated
==7400== 
==7400== LEAK SUMMARY:
==7400==    definitely lost: 0 bytes in 0 blocks
==7400==    indirectly lost: 0 bytes in 0 blocks
==7400==      possibly lost: 860,451 bytes in 132 blocks
==7400==    still reachable: 35,958,126 bytes in 2,750 blocks
==7400==                       of which reachable via heuristic:
==7400==                         newarray           : 1,536 bytes in 16 blocks
==7400==         suppressed: 0 bytes in 0 blocks
==7400== Rerun with --leak-check=full to see details of leaked memory
==7400== 
==7400== For counts of detected and suppressed errors, rerun with: -v
==7400== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)
Note: See TracTickets for help on using tickets.