Opened 5 years ago

Closed 5 years ago

#7918 closed defect (fixed)

ffmpeg segfaults when trim or fade in complex filter is used with HLS

Reported by: pmiller Owned by:
Priority: important Component: undetermined
Version: unspecified Keywords: crash
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:
I want to run a command with a complex filtergraph to trim/fade/scale and generate HLS output.
My test input is a scaled down Big Buck Bunny clip encoded in x264/aac, but it crashes on all the inputs I have tried.

The full complex filter works when I generate two outputs.

ffmpeg -y -nostats -hide_banner -i test.mp4 -filter_complex "[0:v]trim=1.00:duration=5.50,setpts=PTS-STARTPTS,fade=t=in:st=0:d=1.0,fade=t=out:st=1:d=1.0[v0];[0:a]atrim=1.00:duration=5.50,asetpts=PTS-STARTPTS,afade=t=in:st=0:d=1.0,afade=t=out:st=1:d=1.0[a0];[v0]split[ov0][ov01];[a0]asplit[oa0][oa1];[ov01]scale=iw*.5:-1[ov1]" -map "[ov0]" -map "[oa0]" -b:v:0 400k -b:a:0 96k -c:v:0 libx264 -c:a:0 aac av0.mp4 -map "[ov1]" -map "[oa1]" -b:v:1 197k -b:a:1 96k -c:v:1 libx264 -c:a:1 aac av1.mp4

If there is no trim or fade, I can scale the input and generate HLS manifests with fragmented mp4s.

ffmpeg -y -nostats -hide_banner -i test.mp4 -filter_complex "[0:v]split[ov0][ov01];[0:a]asplit[oa0][oa1];[ov01]scale=iw*.5:-1[ov1]" -map "[ov0]" -map "[oa0]" -b:v:0 400k -b:a:0 96k -c:v:0 libx264 -c:a:0 aac -map "[ov1]" -map "[oa1]" -b:v:1 197k -b:a:1 96k -c:v:1 libx264 -c:a:1 aac -var_stream_map "v:0,a:0 v:1,a:1" -hls_time 6 -hls_segment_type fmp4 -f hls -hls_segment_filename segment_%v.mp4 -hls_flags single_file -master_pl_name av1.m3u8 variant_%v.m3u8

If I add trim or fade to the filtergraph, I get a segfault instantly. I tried it with different inputs on MacOS(4.1.3 installed with brew) and ubuntu 16 (apt install).
I ran with -report, but there is no information before the segfault.

How to reproduce:

%ffmpeg -y -nostats -i test.mp4 -filter_complex "[0:v]trim=1.00:duration=5.50,setpts=PTS-STARTPTS,fade=t=in:st=0:d=1.0,fade=t=out:st=1:d=1.0[v0];[0:a]atrim=1.00:duration=5.50,asetpts=PTS-STARTPTS,afade=t=in:st=0:d=1.0,afade=t=out:st=1:d=1.0[a0];[v0]split[ov0][ov01];[a0]asplit[oa0][oa1];[ov01]scale=iw*.5:-1[ov1]" -map "[ov0]" -map "[oa0]" -b:v:0 400k -b:a:0 96k -c:v:0 libx264 -c:a:0 aac -map "[ov1]" -map "[oa1]" -b:v:1 197k -b:a:1 96k -c:v:1 libx264 -c:a:1 aac -var_stream_map "v:0,a:0 v:1,a:1" -hls_time 6 -hls_segment_type fmp4 -f hls -hls_segment_filename segment_%v.mp4 -hls_flags single_file -master_pl_name av1.m3u8 variant_%v.m3u8                        

ffmpeg version 4.1 Copyright (c) 2000-2018 the FFmpeg developers
  built with Apple LLVM version 10.0.0 (clang-1000.11.45.5)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/4.1_3 --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gpl --enable-libaom --enable-libmp3lame --enable-libopus --enable-libsnappy --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-librtmp --enable-libspeex --enable-videotoolbox --disable-libjack --disable-indev=jack
  libavutil      56. 22.100 / 56. 22.100
  libavcodec     58. 35.100 / 58. 35.100
  libavformat    58. 20.100 / 58. 20.100
  libavdevice    58.  5.100 / 58.  5.100
  libavfilter     7. 40.101 /  7. 40.101
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  3.100 /  5.  3.100
  libswresample   3.  3.100 /  3.  3.100
  libpostproc    55.  3.100 / 55.  3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'test.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    title           : Big Buck Bunny
    artist          : Peach Open Movie Team
    composer        : Sacha Goedegebure / Ton Roosendaal
    date            : 2008
    encoder         : Lavf56.25.101
    copyright       : © 2008 Blender Foundation | www.bigbuckbunny.org
  Duration: 00:09:56.50, start: 0.000000, bitrate: 664 kb/s
    Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 640x360, 528 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
Stream mapping:
  Stream #0:0 (h264) -> trim
  Stream #0:1 (aac) -> atrim
  split:output0 -> Stream #0:0 (libx264)
  asplit:output0 -> Stream #0:1 (aac)
  scale -> Stream #0:2 (libx264)
  asplit:output1 -> Stream #0:3 (aac)
Press [q] to stop, [?] for help
[libx264 @ 0x7fcd73831c00] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 @ 0x7fcd73831c00] profile High, level 3.0
[libx264 @ 0x7fcd73831c00] 264 - core 155 r2917 0a84d98 - H.264/MPEG-4 AVC codec - Copyleft 2003-2018 - 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=11 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=abr mbtree=1 bitrate=400 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
[libx264 @ 0x7fcd73834600] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 @ 0x7fcd73834600] profile High, level 1.3
[libx264 @ 0x7fcd73834600] 264 - core 155 r2917 0a84d98 - H.264/MPEG-4 AVC codec - Copyleft 2003-2018 - 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=abr mbtree=1 bitrate=197 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
[hls @ 0x7fcd73830000] Opening 'segment_0.mp4' for writing
[hls @ 0x7fcd73830000] Opening 'segment_1.mp4' for writing
Output #0, hls, to 'variant_%v.m3u8':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    title           : Big Buck Bunny
    artist          : Peach Open Movie Team
    composer        : Sacha Goedegebure / Ton Roosendaal
    date            : 2008
    copyright       : © 2008 Blender Foundation | www.bigbuckbunny.org
    encoder         : Lavf58.20.100
    Stream #0:0: Video: h264 (libx264), yuv420p, 640x360, q=-1--1, 400 kb/s, 30 fps, 15360 tbn, 30 tbc
    Metadata:
      encoder         : Lavc58.35.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/400000 buffer size: 0 vbv_delay: -1
    Stream #0:1: Audio: aac (LC), 44100 Hz, stereo, fltp, 96 kb/s
    Metadata:
      encoder         : Lavc58.35.100 aac
    Stream #0:2: Video: h264 (libx264), yuv420p, 320x180, q=-1--1, 197 kb/s, 30 fps, 15360 tbn, 30 tbc
    Metadata:
      encoder         : Lavc58.35.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/197000 buffer size: 0 vbv_delay: -1
    Stream #0:3: Audio: aac (LC), 44100 Hz, stereo, fltp, 96 kb/s
    Metadata:
      encoder         : Lavc58.35.100 aac
[hls @ 0x7fcd73830000] Cannot use rename on non file protocol, this may lead to races and temporary partial files       
[hls @ 0x7fcd73830000] Opening 'variant_0.m3u8' for writing
[hls @ 0x7fcd73830000] Opening 'variant_1.m3u8' for writing
[hls @ 0x7fcd73830000] Opening 'av1.m3u8' for writing
Segmentation fault: 11

Attachments (1)

ffmpeg-20190522-160904.log (166.5 KB ) - added by pmiller 5 years ago.
-report output

Download all attachments as: .zip

Change History (4)

by pmiller, 5 years ago

Attachment: ffmpeg-20190522-160904.log added

-report output

comment:1 by Carl Eugen Hoyos, 5 years ago

Component: ffmpegundetermined
Keywords: crash added; HLS filter_complex trim fade segfault removed
Version: 4.1unspecified

Please test current FFmpeg git head to make this a valid ticket.

comment:2 by Jun Zhao, 5 years ago

Can't reproduce with commit: 6895b350c31d8fda5bd9e4285c52de6e391e7ff4

comment:3 by Elon Musk, 5 years ago

Resolution: fixed
Status: newclosed

Looks to be fixed.

Note: See TracTickets for help on using tickets.