Opened 4 years ago
Closed 4 years ago
#8843 closed defect (fixed)
concat Segmentation fault filter_complex
Reported by: | Dirk Vanbeveren | Owned by: | Dirk Vanbeveren |
---|---|---|---|
Priority: | important | Component: | avfilter |
Version: | git-master | Keywords: | crash concat amix |
Cc: | vanbeverendirk@hotmail.com | Blocked By: | |
Blocking: | Reproduced by developer: | no | |
Analyzed by developer: | no |
Description
Summary of the bug:
I get a segmentation fault when I combine 3 generated sequences created with 2 files.
Basically sequence 0 contains vid1.mp4 overlayed on a color background 500x500.
Sequence 1 contains a trim of vid1 and vid2 on top of eachother.
Sequence 2 is a part of vid2.
When I concat the 3 sequences in one complex filter I get a segmentation fault.
Although if I concat seq0 and seq1 only I get no error. When I encode seq0 and seq1 to a file and concat that file with seq2 it also poses no problem.
Encoding 3 sequences seperately, then concat the 3 files there is also no error.
How to reproduce:
(code): basically the 3 blocks that start with 'color' represent the 3 sequences with outputs [Seq{sequence#}_out_{v/a}].
Then combined with concat.
ffmpeg -i "vid1.mp4" -i "vid2.mp4" -filter_complex "\ color=s=500x500[Seq0_bg];\ [0:v]trim=0:5,setpts=PTS-STARTPTS[Seq0_0];\ [Seq0_0]scale=w='if(gt(iw/ih,500/(500)),500,-2)':h='if(gt(iw/ih,500/(500)),-2,500)':eval=init[Seq0_0_v];\ [Seq0_bg][Seq0_0_v]overlay=x='(W-w)/2':y='(H-h)/2':eval=init:shortest=1[Seq0_out_v];\ [0:a]atrim=0:5,asetpts=PTS-STARTPTS[Seq0_out_a];\ color=s=500x500[Seq1_bg];\ [0:v]trim=5:10.022,setpts=PTS-STARTPTS[Seq1_0];\ [Seq1_0]scale=w='if(gt(iw/ih,500/(250)),500,-2)':h='if(gt(iw/ih,500/(250)),-2,250)':eval=init[Seq1_0_v];\ [1:v]trim=0:5.022,setpts=PTS-STARTPTS[Seq1_1];\ [Seq1_1]scale=w='if(gt(iw/ih,500/(250)),500,-2)':h='if(gt(iw/ih,500/(250)),-2,250)':eval=init[Seq1_1_v];\ [Seq1_bg][Seq1_0_v]overlay=x='(500-w)/2+0':y='(250-h)/2+0':eval=init:shortest=1[Seq1_overlay_0];\ [Seq1_overlay_0][Seq1_1_v]overlay=x='(500-w)/2+0':y='(250-h)/2+250':eval=init[Seq1_out_v];\ [0:a]atrim=5:10.022,asetpts=PTS-STARTPTS[Seq1_0_a];\ [1:a]atrim=0:5.022,asetpts=PTS-STARTPTS[Seq1_1_a];\ [Seq1_0_a][Seq1_1_a]amix=inputs=2[Seq1_out_a];\ color=s=500x500[Seq2_bg];\ [1:v]trim=5.022:10.024,setpts=PTS-STARTPTS[Seq2_1];\ [Seq2_1]scale=w='if(gt(iw/ih,500/(500)),500,-2)':h='if(gt(iw/ih,500/(500)),-2,500)':eval=init[Seq2_1_v];\ [Seq2_bg][Seq2_1_v]overlay=x='(W-w)/2':y='(H-h)/2':eval=init:shortest=1[Seq2_out_v];\ [1:a]atrim=5.022:10.024,asetpts=PTS-STARTPTS[Seq2_out_a];\ [Seq0_out_v][Seq0_out_a][Seq1_out_v][Seq1_out_a][Seq2_out_v][Seq2_out_a]concat=n=3:v=1:a=1[vid][aud]" \ -map [vid] -map [aud] -y "out.mp4";
ffmpeg version
ffmpeg version 4.2.4-1ubuntu0.1 Copyright (c) 2000-2020 the FFmpeg developers built with gcc 9 (Ubuntu 9.3.0-10ubuntu2) configuration: --prefix=/usr --extra-version=1ubuntu0.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared libavutil 56. 31.100 / 56. 31.100 libavcodec 58. 54.100 / 58. 54.100 libavformat 58. 29.100 / 58. 29.100 libavdevice 58. 8.100 / 58. 8.100 libavfilter 7. 57.100 / 7. 57.100 libavresample 4. 0. 0 / 4. 0. 0 libswscale 5. 5.100 / 5. 5.100 libswresample 3. 5.100 / 3. 5.100 libpostproc 55. 5.100 / 55. 5.100
I attached the logs and the video files. Length of videos are 10s.
Attachments (5)
Change History (22)
by , 4 years ago
Attachment: | output.txt added |
---|
comment:1 by , 4 years ago
Owner: | set to |
---|---|
Status: | new → open |
comment:3 by , 4 years ago
Cc: | removed |
---|
comment:4 by , 4 years ago
Cc: | added |
---|
follow-ups: 7 9 comment:5 by , 4 years ago
Component: | ffmpeg → undetermined |
---|---|
Keywords: | crash added; segmentation fault removed |
Reproduced by developer: | unset |
Version: | 4.2 → unspecified |
Please test current FFmpeg git head and provide the command line you tested together with the complete, uncut console output, backtrace, disassembly and register dump to make this a valid ticket.
comment:6 by , 4 years ago
Summary: | concat Segmentation fault filter_complex → concat Segmentation fault of 3 sources |
---|
comment:7 by , 4 years ago
Replying to cehoyos:
Please test current FFmpeg git head and provide the command line you tested together with the complete, uncut console output, backtrace, disassembly and register dump to make this a valid ticket.
So basically, install from git head, then run code with '-report' and '-loglevel 99' and put those outputs in a file.
then using "gcore -o filename PID" for the register dump.
Is this right?
And what should I do for the disassembly?
comment:8 by , 4 years ago
Summary: | concat Segmentation fault of 3 sources → concat Segmentation fault filter_complex |
---|
comment:9 by , 4 years ago
Replying to cehoyos:
Please test current FFmpeg git head and provide the command line you tested together with the complete, uncut console output, backtrace, disassembly and register dump to make this a valid ticket.
I installed latest ffmpeg from git.
Ran the ffmpeg command with '-loglevel 99 -report' and put the output report as attachment.
ran "gcore -o output [PID]" on process creation and put the output file as attachment.
comment:10 by , 4 years ago
Version: | unspecified → git-master |
---|
follow-up: 12 comment:11 by , 4 years ago
Simplified command-line:
./ffmpeg_g -loglevel verbose -i /tmp/vid1.mp4 -filter_complex " testsrc2=s=16x16:r=25:d=0.062 [v1] ; testsrc2=s=16x16:r=24:d=0.040 [v2] ; anullsrc , atrim=0:0.062 [a2] ; anullsrc , atrim=0:0.040 [a3] ; [0:a]atrim=9.960:10.022 , asetpts=PTS-STARTPTS[a1] ; [a1][a2]amix=inputs=2[Seq1_out_a] ; [v1][Seq1_out_a][v2][a3]concat=n=2:v=1:a=1[vid][aud]" -map "[vid]" -map "[aud] " -f null -
Removing input from the file or amix make the bug disappear.
comment:12 by , 4 years ago
Replying to Cigaes:
Simplified command-line:
./ffmpeg_g -loglevel verbose -i /tmp/vid1.mp4 -filter_complex " testsrc2=s=16x16:r=25:d=0.062 [v1] ; testsrc2=s=16x16:r=24:d=0.040 [v2] ; anullsrc , atrim=0:0.062 [a2] ; anullsrc , atrim=0:0.040 [a3] ; [0:a]atrim=9.960:10.022 , asetpts=PTS-STARTPTS[a1] ; [a1][a2]amix=inputs=2[Seq1_out_a] ; [v1][Seq1_out_a][v2][a3]concat=n=2:v=1:a=1[vid][aud]" -map "[vid]" -map "[aud] " -f null -Removing input from the file or amix make the bug disappear.
Just combining 2 of the streams poses no problem. But combining the 3 does.
This command works flawlessly:
ffmpeg -i vid1.mp4 -i vid2.mp4 -filter_complex "\ color=s=500x500[Seq0_bg];\ [0:v]trim=0:5,setpts=PTS-STARTPTS, scale=w=500:h=500:eval=init[Seq0_0_v];\ [Seq0_bg][Seq0_0_v]overlay=x=0:y=0:eval=init:shortest=1[Seq0_out_v];\ [0:a]atrim=0:5,asetpts=PTS-STARTPTS[Seq0_out_a];\ color=s=500x500[Seq1_bg];\ [0:v]trim=5:10.022,setpts=PTS-STARTPTS,scale=w=500:h=250:eval=init[Seq1_0_v];\ [1:v]trim=0:5.022,setpts=PTS-STARTPTS,scale=w=500:h=250:eval=init[Seq1_1_v];\ [Seq1_bg][Seq1_0_v]overlay=x=0:y=0:eval=init:shortest=1[Seq1_overlay_0];\ [Seq1_overlay_0][Seq1_1_v]overlay=x=0:y=250[Seq1_out_v];\ [0:a]atrim=5:10.022,asetpts=PTS-STARTPTS[Seq1_0_a];\ [1:a]atrim=0:5.022,asetpts=PTS-STARTPTS[Seq1_1_a];\ [Seq1_0_a][Seq1_1_a]amix=inputs=2[Seq1_out_a];\ [Seq0_out_v][Seq0_out_a][Seq1_out_v][Seq1_out_a]concat=n=2:v=1:a=1[vid][aud]" \ -map [vid] -map [aud] -y out.mp4
follow-up: 14 comment:13 by , 4 years ago
Component: | undetermined → avfilter |
---|---|
Keywords: | amix added; concat removed |
I very much confirm the command-line I gave reproduces the problem with only two segments.
The problem seems to be in the amix filter: it sends the last frame without a timestamp. The following patch protects concat from it and prevents the segfault, resulting in an error with a message instead.
https://ffmpeg.org/pipermail/ffmpeg-devel/2020-August/267563.html
For a proper fix, amix needs to be investigated.
I suggest trying to use amerge and pan instead.
comment:14 by , 4 years ago
Replying to Cigaes:
I very much confirm the command-line I gave reproduces the problem with only two segments.
The problem seems to be in the amix filter: it sends the last frame without a timestamp. The following patch protects concat from it and prevents the segfault, resulting in an error with a message instead.
https://ffmpeg.org/pipermail/ffmpeg-devel/2020-August/267563.html
For a proper fix, amix needs to be investigated.
I suggest trying to use amerge and pan instead.
Sorry, I thought you said your code did work. Indeed your code also caused the segmentation fault as I ran it.
Thank you for the suggestion. I'm going to try to implement amix with amerge and pan like you said; for now at least. Hopefully it works. :)
follow-up: 16 comment:15 by , 4 years ago
Keywords: | concat added |
---|---|
Priority: | normal → important |
The posted patch seems to indicate that there is a crash in the concat filter...
comment:16 by , 4 years ago
Replying to cehoyos:
The posted patch seems to indicate that there is a crash in the concat filter...
Yes indeed. In the end concat should be able to handle the the exception and amix should fix its output.
comment:17 by , 4 years ago
Resolution: | → fixed |
---|---|
Status: | open → closed |
Fixed in 17b44f759e8cbb6952c0ae2 and 05c8d0bce64888c531282
output logs of command run