Opened 3 years ago
Closed 3 months ago
#9719 closed defect (fixed)
FFmpeg HLS output with subtitles results in segmentation fault starting from 5.x
Reported by: | wout | Owned by: | |
---|---|---|---|
Priority: | normal | Component: | undetermined |
Version: | git-master | Keywords: | |
Cc: | Blocked By: | ||
Blocking: | Reproduced by developer: | no | |
Analyzed by developer: | no |
Description (last modified by )
I am trying to create a HLS output for multiple video, audio and subtitles. I map the lowest video stream (0:v:2) multiple times to allow using it in the var_stream_map
for subtitle only entries. This is needed because I cannot specify an entry without a video (for example "s:0,name:en,sgroup:subtitle,language:en,default:NO" is not allowed)
ffmpeg -re -fflags +genpts -i /path/to/multilang.mp4 -i /path/to/en.vtt -i /path/to/it.vtt -i /path/to/de.vtt -i /path/to/ru.vtt -i /path/to/fa.vtt -i /path/to/da.vtt -i /path/to/es.vtt -i /path/to/hr.vtt -c:a copy -c:v copy -c:s webvtt -map 1:s:0 -map 2:s:0 -map 3:s:0 -map 4:s:0 -map 5:s:0 -map 6:s:0 -map 7:s:0 -map 8:s:0 -map 0:v:2 -map 0:v:2 -map 0:v:2 -map 0:v:2 -map 0:v:2 -map 0:v:2 -map 0:v:2 -map 0:v:2 -map 0:a:0 -map 0:a:1 -map 0:a:2 -map 0:a:3 -map 0:a:4 -map 0:a:5 -map 0:a:6 -map 0:v:0 -map 0:v:1 -map 0:v:2 -map 0:v:3 -map 0:v:4 -max_interleave_delta 10000000 -muxdelay 0 -f hls -var_stream_map "a:0,name:en_audio,agroup:audio,language:en,default:YES a:1,name:it_audio,agroup:audio,language:it,default:NO a:2,name:ru_audio,agroup:audio,language:ru,default:NO a:3,name:ar_audio,agroup:audio,language:ar,default:NO a:4,name:da_audio,agroup:audio,language:da,default:NO a:5,name:sw_audio,agroup:audio,language:sw,default:NO a:6,name:zh_audio,agroup:audio,language:zh,default:NO v:0,name:en,s:0,sgroup:subtitle,language:en,default:NO v:1,name:it,s:1,sgroup:subtitle,language:it,default:NO v:2,name:de,s:2,sgroup:subtitle,language:de,default:NO v:3,name:ru,s:3,sgroup:subtitle,language:ru,default:NO v:4,name:fa,s:4,sgroup:subtitle,language:fa,default:NO v:5,name:da,s:5,sgroup:subtitle,language:da,default:NO v:6,name:es,s:6,sgroup:subtitle,language:es,default:NO v:7,name:hr,s:7,sgroup:subtitle,language:hr,default:NO v:8,name:1080p,agroup:audio v:9,name:720p,agroup:audio v:10,name:480p,agroup:audio v:11,name:360p,agroup:audio v:12,name:240p,agroup:audio" -master_pl_name master.m3u8 -hls_delete_threshold 4 -hls_segment_filename "/path/to/hls/%v_%d.ts" -hls_start_number_source datetime -hls_time 10 -hls_init_time 10 -hls_list_size 6 -hls_flags delete_segments+independent_segments+round_durations "/path/to/hls/%v.m3u8"
This worked perfectly in previous FFmpeg versions, but starting from 5.x
this results in a segmentation fault:
Program terminated with signal SIGSEGV, Segmentation fault. #0 0x000056073c3a6edd in ff_write_chained (dst=0x56073f3eda40, dst_stream=-1, pkt=0x56073ea5d4c0, src=<optimized out>, interleave=0) at libavformat/mux.c:1310
(gdb) backtrace #0 0x000055ec0a65f9ed in ff_write_chained (dst=0x55ec0d193800, dst_stream=-8, pkt=0x55ec0ceda380, src=<optimized out>, interleave=0) at libavformat/mux.c:1363 #1 0x000055ec0a5e87fb in hls_write_packet (s=<optimized out>, pkt=0x55ec0ceda380) at libavformat/hlsenc.c:2669 #2 0x000055ec0a65c864 in write_packet (s=s@entry=0x55ec0d1a3900, pkt=pkt@entry=0x55ec0ceda380) at libavformat/mux.c:771 #3 0x000055ec0a65cd7b in interleaved_write_packet (has_packet=0, flush=<optimized out>, pkt=<optimized out>, s=<optimized out>) at libavformat/mux.c:1145 #4 write_packet_common (s=s@entry=0x55ec0d1a3900, st=<optimized out>, pkt=pkt@entry=0x55ec0ceda380, interleaved=interleaved@entry=1) at libavformat/mux.c:1170 #5 0x000055ec0a65df5b in write_packets_common (s=s@entry=0x55ec0d1a3900, pkt=pkt@entry=0x55ec0ceda380, interleaved=interleaved@entry=1) at libavformat/mux.c:1230 #6 0x000055ec0a65f65a in write_packets_common (interleaved=1, pkt=0x55ec0ceda380, s=0x55ec0d1a3900) at libavformat/mux.c:1214 #7 av_interleaved_write_frame (s=s@entry=0x55ec0d1a3900, pkt=pkt@entry=0x55ec0ceda380) at libavformat/mux.c:1286 #8 0x000055ec0a2b53f0 in of_write_packet (of=<optimized out>, pkt=0x55ec0ceda380, ost=0x55ec0ced9940, unqueue=<optimized out>) at fftools/ffmpeg_mux.c:181 #9 0x000055ec0a2d4e88 in do_streamcopy (pkt=<optimized out>, ost=<optimized out>, ist=<optimized out>) at fftools/ffmpeg.c:1938 #10 process_input_packet (ist=<optimized out>, pkt=<optimized out>, no_eof=<optimized out>) at fftools/ffmpeg.c:2601 #11 0x000055ec0a2d7666 in process_input (file_index=<optimized out>) at fftools/ffmpeg.c:4225 #12 transcode_step () at fftools/ffmpeg.c:4365 #13 transcode () at fftools/ffmpeg.c:4419 #14 0x000055ec0a2b0cbe in main (argc=109, argv=0x7ffd7456d108) at fftools/ffmpeg.c:4625
It is caused by commit c64d56a2f53455f803456811873ff08fce98e122 as reverting it resolves the issue.
Change History (10)
comment:1 by , 3 years ago
Description: | modified (diff) |
---|---|
Version: | unspecified → git-master |
comment:2 by , 18 months ago
comment:4 by , 4 months ago
As a workaround I still revert the commit in the original report with FFmpeg 7.x.
comment:5 by , 4 months ago
Please provide the command line you tested together with the complete, uncut console output to make this a valid question.
follow-up: 8 comment:7 by , 4 months ago
The following command triggers the segmentation fault.
You can use any input MP4 with 1 video and 1 audio + empty files for the VTT's.
The video track is mapped multiple times because we cannot define multiple subtitles in the var_stream_map
without a video.
The commit mentioned in the original report causes a segmentation fault because of this. Reverting it produces a correct HLS.
The audio track is mapped multiple times just to simulate multiple audio languages.
ffmpeg -i input.mp4 -i en.vtt -i nl.vtt -c copy -map 0:v:0 -map 0:v:0 -map 0:v:0 -map 0:a:0 -map 0:a:0 -map 1:s:0 -map 2:s:0 -f hls -var_stream_map "a:0,name:en_audio,agroup:audio,language:en,default:YES a:1,name:nl_audio,agroup:audio,language:nl,default:NO v:0,name:en,s:0,sgroup:subtitle,language:en,default:NO v:1,name:nl,s:1,sgroup:subtitle,language:nl,default:NO v:2,name:high,agroup:audio" "%v.m3u8"
Output:
ffmpeg version 7.0.1 Copyright (c) 2000-2024 the FFmpeg developers built with gcc 12 (Debian 12.2.0-14) configuration: --prefix=/usr/local --toolchain=hardened --enable-gpl --enable-version3 --enable-nonfree --enable-postproc --enable-avfilter --enable-libfontconfig --enable-libfreetype --enable-pthreads --enable-libopenjpeg --enable-gmp --enable-openssl --enable-libx264 --enable-libx265 --enable-libzmq --enable-libsrt --enable-libnpp --enable-cuda --enable-cuda-nvcc --enable-cuvid --enable-nvenc --enable-filter=scale_cuda --enable-filter=hwupload_cuda --enable-filter=hwdownload --enable-filter=thumbnail_cuda --extra-cflags=-I/usr/local/cuda/include --extra-ldflags=-L/usr/local/cuda/lib64 libavutil 59. 8.100 / 59. 8.100 libavcodec 61. 3.100 / 61. 3.100 libavformat 61. 1.100 / 61. 1.100 libavdevice 61. 1.100 / 61. 1.100 libavfilter 10. 1.100 / 10. 1.100 libswscale 8. 1.100 / 8. 1.100 libswresample 5. 1.100 / 5. 1.100 libpostproc 58. 1.100 / 58. 1.100 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'input.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf58.45.100 Duration: 00:03:47.46, start: 0.000000, bitrate: 2513 kb/s Stream #0:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709, progressive), 1458x1080 [SAR 1:1 DAR 27:20], 2380 kb/s, 23.98 fps, 23.98 tbr, 24k tbn (default) Metadata: handler_name : ISO Media file produced by Google Inc. vendor_id : [0][0][0][0] Stream #0:1[0x2](und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 127 kb/s (default) Metadata: handler_name : ISO Media file produced by Google Inc. vendor_id : [0][0][0][0] Input #1, webvtt, from 'en.vtt': Duration: N/A, bitrate: N/A Stream #1:0: Subtitle: webvtt Input #2, webvtt, from 'nl.vtt': Duration: N/A, bitrate: N/A Stream #2:0: Subtitle: webvtt Stream mapping: Stream #0:0 -> #0:0 (copy) Stream #0:0 -> #0:1 (copy) Stream #0:0 -> #0:2 (copy) Stream #0:1 -> #0:3 (copy) Stream #0:1 -> #0:4 (copy) Stream #1:0 -> #0:5 (copy) Stream #2:0 -> #0:6 (copy) [mpegts @ 0x5650f6143b80] frame size not set [mpegts @ 0x5650f614fac0] frame size not set [hls @ 0x5650f611c140] Opening 'en0.vtt' for writing [hls @ 0x5650f611c140] Opening 'nl0.vtt' for writing Output #0, hls, to '%v.m3u8': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf61.1.100 Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709, progressive), 1458x1080 [SAR 1:1 DAR 27:20], q=2-31, 2380 kb/s, 23.98 fps, 23.98 tbr, 90k tbn (default) Metadata: handler_name : ISO Media file produced by Google Inc. vendor_id : [0][0][0][0] Stream #0:1(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709, progressive), 1458x1080 [SAR 1:1 DAR 27:20], q=2-31, 2380 kb/s, 23.98 fps, 23.98 tbr, 90k tbn (default) Metadata: handler_name : ISO Media file produced by Google Inc. vendor_id : [0][0][0][0] Stream #0:2(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709, progressive), 1458x1080 [SAR 1:1 DAR 27:20], q=2-31, 2380 kb/s, 23.98 fps, 23.98 tbr, 90k tbn (default) Metadata: handler_name : ISO Media file produced by Google Inc. vendor_id : [0][0][0][0] Stream #0:3(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 127 kb/s (default) Metadata: handler_name : ISO Media file produced by Google Inc. vendor_id : [0][0][0][0] Stream #0:4(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 127 kb/s (default) Metadata: handler_name : ISO Media file produced by Google Inc. vendor_id : [0][0][0][0] Stream #0:5: Subtitle: webvtt (default) Stream #0:6: Subtitle: webvtt Press [q] to stop, [?] for help Segmentation fault
comment:8 by , 3 months ago
Replying to wout:
The following command triggers the segmentation fault.
You can use any input MP4 with 1 video and 1 audio + empty files for the VTT's.
The video track is mapped multiple times because we cannot define multiple subtitles in the
var_stream_map
without a video.
The commit mentioned in the original report causes a segmentation fault because of this. Reverting it produces a correct HLS.
The audio track is mapped multiple times just to simulate multiple audio languages.
ffmpeg -i input.mp4 -i en.vtt -i nl.vtt -c copy -map 0:v:0 -map 0:v:0 -map 0:v:0 -map 0:a:0 -map 0:a:0 -map 1:s:0 -map 2:s:0 -f hls -var_stream_map "a:0,name:en_audio,agroup:audio,language:en,default:YES a:1,name:nl_audio,agroup:audio,language:nl,default:NO v:0,name:en,s:0,sgroup:subtitle,language:en,default:NO v:1,name:nl,s:1,sgroup:subtitle,language:nl,default:NO v:2,name:high,agroup:audio" "%v.m3u8"
Output:
ffmpeg version 7.0.1 Copyright (c) 2000-2024 the FFmpeg developers built with gcc 12 (Debian 12.2.0-14) configuration: --prefix=/usr/local --toolchain=hardened --enable-gpl --enable-version3 --enable-nonfree --enable-postproc --enable-avfilter --enable-libfontconfig --enable-libfreetype --enable-pthreads --enable-libopenjpeg --enable-gmp --enable-openssl --enable-libx264 --enable-libx265 --enable-libzmq --enable-libsrt --enable-libnpp --enable-cuda --enable-cuda-nvcc --enable-cuvid --enable-nvenc --enable-filter=scale_cuda --enable-filter=hwupload_cuda --enable-filter=hwdownload --enable-filter=thumbnail_cuda --extra-cflags=-I/usr/local/cuda/include --extra-ldflags=-L/usr/local/cuda/lib64 libavutil 59. 8.100 / 59. 8.100 libavcodec 61. 3.100 / 61. 3.100 libavformat 61. 1.100 / 61. 1.100 libavdevice 61. 1.100 / 61. 1.100 libavfilter 10. 1.100 / 10. 1.100 libswscale 8. 1.100 / 8. 1.100 libswresample 5. 1.100 / 5. 1.100 libpostproc 58. 1.100 / 58. 1.100 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'input.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf58.45.100 Duration: 00:03:47.46, start: 0.000000, bitrate: 2513 kb/s Stream #0:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709, progressive), 1458x1080 [SAR 1:1 DAR 27:20], 2380 kb/s, 23.98 fps, 23.98 tbr, 24k tbn (default) Metadata: handler_name : ISO Media file produced by Google Inc. vendor_id : [0][0][0][0] Stream #0:1[0x2](und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 127 kb/s (default) Metadata: handler_name : ISO Media file produced by Google Inc. vendor_id : [0][0][0][0] Input #1, webvtt, from 'en.vtt': Duration: N/A, bitrate: N/A Stream #1:0: Subtitle: webvtt Input #2, webvtt, from 'nl.vtt': Duration: N/A, bitrate: N/A Stream #2:0: Subtitle: webvtt Stream mapping: Stream #0:0 -> #0:0 (copy) Stream #0:0 -> #0:1 (copy) Stream #0:0 -> #0:2 (copy) Stream #0:1 -> #0:3 (copy) Stream #0:1 -> #0:4 (copy) Stream #1:0 -> #0:5 (copy) Stream #2:0 -> #0:6 (copy) [mpegts @ 0x5650f6143b80] frame size not set [mpegts @ 0x5650f614fac0] frame size not set [hls @ 0x5650f611c140] Opening 'en0.vtt' for writing [hls @ 0x5650f611c140] Opening 'nl0.vtt' for writing Output #0, hls, to '%v.m3u8': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf61.1.100 Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709, progressive), 1458x1080 [SAR 1:1 DAR 27:20], q=2-31, 2380 kb/s, 23.98 fps, 23.98 tbr, 90k tbn (default) Metadata: handler_name : ISO Media file produced by Google Inc. vendor_id : [0][0][0][0] Stream #0:1(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709, progressive), 1458x1080 [SAR 1:1 DAR 27:20], q=2-31, 2380 kb/s, 23.98 fps, 23.98 tbr, 90k tbn (default) Metadata: handler_name : ISO Media file produced by Google Inc. vendor_id : [0][0][0][0] Stream #0:2(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709, progressive), 1458x1080 [SAR 1:1 DAR 27:20], q=2-31, 2380 kb/s, 23.98 fps, 23.98 tbr, 90k tbn (default) Metadata: handler_name : ISO Media file produced by Google Inc. vendor_id : [0][0][0][0] Stream #0:3(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 127 kb/s (default) Metadata: handler_name : ISO Media file produced by Google Inc. vendor_id : [0][0][0][0] Stream #0:4(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 127 kb/s (default) Metadata: handler_name : ISO Media file produced by Google Inc. vendor_id : [0][0][0][0] Stream #0:5: Subtitle: webvtt (default) Stream #0:6: Subtitle: webvtt Press [q] to stop, [?] for help Segmentation fault
pull the master branch and test it please, look Btbn has been fix this ticket by commit 817c6a6762696e6efee44ddc4e2d706922b880e0
comment:10 by , 3 months ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Hello, any progerss on this issue ? We are stuck on using 4.x version of FFMPEG due to this bug.