Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#8200 closed defect (worksforme)

ffmpeg crash with -vcodec libx264

Reported by: doleva Owned by:
Priority: normal Component: undetermined
Version: git-master Keywords: libx264 crash
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:
FFmpeg crashes (Segmentation fault) when trying to encode with libx264. Weirdly - it behaves inconsistently: trying a lot of times, sometimes it just works and sometimes crashes right after the probing level.
Tested with multiple inputs and output formats - does not seem to matter.
How to reproduce:
ffmpeg -i anyfile.anyformat -vcodec libx264 output.anyformat
supplied report logs, output of gdb and output of high loglevel

Attachments (5)

ffmpeg_bug_outputs.zip (191.5 KB ) - added by doleva 5 years ago.
debug-output.txt (16.1 KB ) - added by doleva 5 years ago.
output.txt (814.4 KB ) - added by doleva 5 years ago.
ffmpeg-20190925-131333.log (179.5 KB ) - added by doleva 5 years ago.
ffmpeg-20190925-133044.log (814.7 KB ) - added by doleva 5 years ago.

Download all attachments as: .zip

Change History (13)

by doleva, 5 years ago

Attachment: ffmpeg_bug_outputs.zip added

comment:1 by Carl Eugen Hoyos, 5 years ago

Component: ffmpegundetermined
Keywords: libx264 crash added

You do realize that by compressing the logs, you make it as difficult as possible to reproduce this issue?

Is the issue reproducible with testsrc2=s=hd720?

by doleva, 5 years ago

Attachment: debug-output.txt added

by doleva, 5 years ago

Attachment: output.txt added

by doleva, 5 years ago

Attachment: ffmpeg-20190925-131333.log added

by doleva, 5 years ago

Attachment: ffmpeg-20190925-133044.log added

comment:2 by doleva, 5 years ago

I did not realise, apologies. Uploaded uncompressed logs.

Yes - reproduced with:

ffmpeg -f lavfi -i testsrc2=s=hd720 -vcodec libx264 out.mp4

comment:3 by Carl Eugen Hoyos, 5 years ago

This looks like an issue that cannot be fixed in FFmpeg, please test an older version of libx264.

comment:4 by Carl Eugen Hoyos, 5 years ago

Or test a newer compiler, yours is very old.

in reply to:  4 comment:5 by doleva, 5 years ago

Replying to cehoyos:

Or test a newer compiler, yours is very old.

Upgraded the compiler, did not help:

$ ffmpeg -y -t 5 -f lavfi -i testsrc2=s=hd720 -vcodec libx264 out.mp4
ffmpeg version N-95056-g5f13859 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-39)
  configuration: --pkg-config-flags=--static --enable-static --enable-gpl --enable-nonfree --enable-libx264 --extra-cflags=-I/usr/local/include --extra-ldflags=-L/usr/local/lib --extra-libs='-lx264 -lpthread -lm -ldl'
  libavutil      56. 35.100 / 56. 35.100
  libavcodec     58. 58.101 / 58. 58.101
  libavformat    58. 33.100 / 58. 33.100
  libavdevice    58.  9.100 / 58.  9.100
  libavfilter     7. 58.102 /  7. 58.102
  libswscale      5.  6.100 /  5.  6.100
  libswresample   3.  6.100 /  3.  6.100
  libpostproc    55.  6.100 / 55.  6.100
Input #0, lavfi, from 'testsrc2=s=hd720':
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 25 tbr, 25 tbn, 25 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (libx264))
Press [q] to stop, [?] for help
[libx264 @ 0x36bb280] using SAR=1/1
[libx264 @ 0x36bb280] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0x36bb280] profile High, level 3.1, 4:2:0, 8-bit
[libx264 @ 0x36bb280] 264 - core 158 r2984 3759fcb - H.264/MPEG-4 AVC codec - Copyleft 2003-2019 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'out.mp4':
  Metadata:
    encoder         : Lavf58.33.100
    Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=-1--1, 25 fps, 12800 tbn, 25 tbc
    Metadata:
      encoder         : Lavc58.58.101 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
Segmentation fault (core dumped)

Will try older versions of libx264...

comment:6 by Carl Eugen Hoyos, 5 years ago

Please test gcc-6.4.0 or similar

comment:7 by Carl Eugen Hoyos, 5 years ago

Resolution: worksforme
Status: newclosed

I cannot reproduce the issue with an even older compiler, analysis showed that if there is an issue, it is most likely in x264 and cannot be fixed in FFmpeg.

$ ffmpeg -y -t 5 -f lavfi -i testsrc2=s=hd720 -vcodec libx264 out.mp4
ffmpeg version N-95072-gced3b8c61e Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 4.4.6 (GCC)
  configuration: --cc=/mnt/sdb6/cehoyos/gcc/gcc-4.4.6/bin/gcc --enable-gpl --enable-libx264 --extra-cflags=-I../x264 --extra-ldflags=-L../x264 --disable-v4l2-m2m --disable-libxcb --disable-alsa --disable-zlib --disable-bzlib --disable-vdpau --disable-lzma --disable-vaapi --disable-sdl2
  libavutil      56. 35.100 / 56. 35.100
  libavcodec     58. 59.100 / 58. 59.100
  libavformat    58. 33.100 / 58. 33.100
  libavdevice    58.  9.100 / 58.  9.100
  libavfilter     7. 59.100 /  7. 59.100
  libswscale      5.  6.100 /  5.  6.100
  libswresample   3.  6.100 /  3.  6.100
  libpostproc    55.  6.100 / 55.  6.100
Input #0, lavfi, from 'testsrc2=s=hd720':
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 25 tbr, 25 tbn, 25 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (libx264))
Press [q] to stop, [?] for help
[libx264 @ 0x2bb0ec0] using SAR=1/1
[libx264 @ 0x2bb0ec0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0x2bb0ec0] profile High, level 3.1, 4:2:0, 8-bit
[libx264 @ 0x2bb0ec0] 264 - core 158 r2984 3759fcb - H.264/MPEG-4 AVC codec - Copyleft 2003-2019 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=22 lookahead_threads=3 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'out.mp4':
  Metadata:
    encoder         : Lavf58.33.100
    Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=-1--1, 25 fps, 12800 tbn, 25 tbc
    Metadata:
      encoder         : Lavc58.59.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
frame=  125 fps=0.0 q=-1.0 Lsize=    1702kB time=00:00:04.88 bitrate=2857.2kbits/s speed=7.05x    
video:1700kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.135187%
[libx264 @ 0x2bb0ec0] frame I:1     Avg QP:14.53  size: 24526
[libx264 @ 0x2bb0ec0] frame P:60    Avg QP:25.57  size: 16360
[libx264 @ 0x2bb0ec0] frame B:64    Avg QP:30.06  size: 11465
[libx264 @ 0x2bb0ec0] consecutive B-frames:  7.2% 72.0%  4.8% 16.0%
[libx264 @ 0x2bb0ec0] mb I  I16..4: 56.5% 34.6%  8.9%
[libx264 @ 0x2bb0ec0] mb P  I16..4:  0.9%  4.2%  1.1%  P16..4:  6.6%  4.1%  2.5%  0.0%  0.0%    skip:80.6%
[libx264 @ 0x2bb0ec0] mb B  I16..4:  0.2%  0.8%  0.6%  B16..8:  9.4%  2.9%  0.7%  direct: 1.1%  skip:84.3%  L0:47.8% L1:42.0% BI:10.3%
[libx264 @ 0x2bb0ec0] 8x8 transform intra:58.6% inter:26.2%
[libx264 @ 0x2bb0ec0] coded y,uvDC,uvAC intra: 24.2% 32.7% 32.2% inter: 3.6% 6.8% 6.1%
[libx264 @ 0x2bb0ec0] i16 v,h,dc,p: 80% 16%  3%  0%
[libx264 @ 0x2bb0ec0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu:  7% 12% 75%  2%  1%  1%  1%  1%  1%
[libx264 @ 0x2bb0ec0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 21% 24% 34%  5%  3%  3%  3%  4%  4%
[libx264 @ 0x2bb0ec0] i8c dc,h,v,p: 75% 11% 11%  3%
[libx264 @ 0x2bb0ec0] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x2bb0ec0] ref P L0: 48.7%  7.3% 29.0% 15.0%
[libx264 @ 0x2bb0ec0] ref B L0: 72.4% 26.0%  1.6%
[libx264 @ 0x2bb0ec0] ref B L1: 98.1%  1.9%
[libx264 @ 0x2bb0ec0] kb/s:2783.77

Note that the fact that the crash is not always reproducible may indicate a hardware issue.

in reply to:  7 comment:8 by doleva, 5 years ago

Replying to cehoyos:

I cannot reproduce the issue with an even older compiler, analysis showed that if there is an issue, it is most likely in x264 and cannot be fixed in FFmpeg.

$ ffmpeg -y -t 5 -f lavfi -i testsrc2=s=hd720 -vcodec libx264 out.mp4
ffmpeg version N-95072-gced3b8c61e Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 4.4.6 (GCC)
  configuration: --cc=/mnt/sdb6/cehoyos/gcc/gcc-4.4.6/bin/gcc --enable-gpl --enable-libx264 --extra-cflags=-I../x264 --extra-ldflags=-L../x264 --disable-v4l2-m2m --disable-libxcb --disable-alsa --disable-zlib --disable-bzlib --disable-vdpau --disable-lzma --disable-vaapi --disable-sdl2
  libavutil      56. 35.100 / 56. 35.100
  libavcodec     58. 59.100 / 58. 59.100
  libavformat    58. 33.100 / 58. 33.100
  libavdevice    58.  9.100 / 58.  9.100
  libavfilter     7. 59.100 /  7. 59.100
  libswscale      5.  6.100 /  5.  6.100
  libswresample   3.  6.100 /  3.  6.100
  libpostproc    55.  6.100 / 55.  6.100
Input #0, lavfi, from 'testsrc2=s=hd720':
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 25 tbr, 25 tbn, 25 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (libx264))
Press [q] to stop, [?] for help
[libx264 @ 0x2bb0ec0] using SAR=1/1
[libx264 @ 0x2bb0ec0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0x2bb0ec0] profile High, level 3.1, 4:2:0, 8-bit
[libx264 @ 0x2bb0ec0] 264 - core 158 r2984 3759fcb - H.264/MPEG-4 AVC codec - Copyleft 2003-2019 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=22 lookahead_threads=3 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'out.mp4':
  Metadata:
    encoder         : Lavf58.33.100
    Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=-1--1, 25 fps, 12800 tbn, 25 tbc
    Metadata:
      encoder         : Lavc58.59.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
frame=  125 fps=0.0 q=-1.0 Lsize=    1702kB time=00:00:04.88 bitrate=2857.2kbits/s speed=7.05x    
video:1700kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.135187%
[libx264 @ 0x2bb0ec0] frame I:1     Avg QP:14.53  size: 24526
[libx264 @ 0x2bb0ec0] frame P:60    Avg QP:25.57  size: 16360
[libx264 @ 0x2bb0ec0] frame B:64    Avg QP:30.06  size: 11465
[libx264 @ 0x2bb0ec0] consecutive B-frames:  7.2% 72.0%  4.8% 16.0%
[libx264 @ 0x2bb0ec0] mb I  I16..4: 56.5% 34.6%  8.9%
[libx264 @ 0x2bb0ec0] mb P  I16..4:  0.9%  4.2%  1.1%  P16..4:  6.6%  4.1%  2.5%  0.0%  0.0%    skip:80.6%
[libx264 @ 0x2bb0ec0] mb B  I16..4:  0.2%  0.8%  0.6%  B16..8:  9.4%  2.9%  0.7%  direct: 1.1%  skip:84.3%  L0:47.8% L1:42.0% BI:10.3%
[libx264 @ 0x2bb0ec0] 8x8 transform intra:58.6% inter:26.2%
[libx264 @ 0x2bb0ec0] coded y,uvDC,uvAC intra: 24.2% 32.7% 32.2% inter: 3.6% 6.8% 6.1%
[libx264 @ 0x2bb0ec0] i16 v,h,dc,p: 80% 16%  3%  0%
[libx264 @ 0x2bb0ec0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu:  7% 12% 75%  2%  1%  1%  1%  1%  1%
[libx264 @ 0x2bb0ec0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 21% 24% 34%  5%  3%  3%  3%  4%  4%
[libx264 @ 0x2bb0ec0] i8c dc,h,v,p: 75% 11% 11%  3%
[libx264 @ 0x2bb0ec0] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x2bb0ec0] ref P L0: 48.7%  7.3% 29.0% 15.0%
[libx264 @ 0x2bb0ec0] ref B L0: 72.4% 26.0%  1.6%
[libx264 @ 0x2bb0ec0] ref B L1: 98.1%  1.9%
[libx264 @ 0x2bb0ec0] kb/s:2783.77

Note that the fact that the crash is not always reproducible may indicate a hardware issue.

I change libx264 branch from master to "stable" - seems like the problem is gone.
I'm not sure it is hw because I tried it on two different VMs (different hosts, CentOS and RHEL 7) - could reproduce after some point.
Will try newer compiler - but will continue with x264 mailing list.
Thank you very much for your help!

Note: See TracTickets for help on using tickets.