Opened 2 years ago

Closed 2 months ago

#9877 closed defect (fixed)

ffmpeg core dumped error when map webvtt subtitles

Reported by: tudge Owned by:
Priority: important Component: avformat
Version: git-master Keywords: hls crash SIGSEGV regression
Cc: Blocked By:
Blocking: Reproduced by developer: yes
Analyzed by developer: no

Description (last modified by tudge)

ffmpeg giving core dumped, segmentation fault error when adding webvtt subtitles to mapping on any MKV file or Live stream encoding.
Without subtitles all working fine.
Here is the code I use:

./ffmpeg \
-y -vsync 0 -hwaccel cuda -hwaccel_output_format cuda \
-v 9 -loglevel debug \
-report \
-fix_sub_duration \
-i "http://192.168.3.3/any.mkv" \
-map 0:0 -vf scale_cuda=w=1280:h=720 -c:v:0 h264_nvenc -b:v:0 6M \
-map 0:0 -vf scale_cuda=w=1280:h=720 -c:v:1 h264_nvenc -b:v:1 3M \
-map a:0 -c:a:0 aac -b:a:0 128k -ac 2 \
-map a:1 -c:a:1 aac -b:a:1 128k -ac 2 \
-c:s webvtt \
-map s:0 \
-map s:1 \
-f hls \
-hls_time 6 \
-hls_playlist_type event \
-hls_flags independent_segments \
-master_pl_name master.m3u8 \
-hls_segment_type mpegts \
-hls_segment_filename http://192.168.3.3/any/chunk_%02d%v.ts \
-var_stream_map "a:0,agroup:aud,name:rus,language:rus,default:YES a:1,agroup:aud,name:eng,language:English,default:NO v:0,name:1080p,agroup:aud,s:0 v:1,name:720p,agroup:aud,s:1" http://192.168.3.3/any/stream_%v.m3u8

full output with logs in attached file.

Attachments (2)

ffmpeg-20220813-222417.log (2.1 MB ) - added by tudge 2 years ago.
full output
any.mkv (679.5 KB ) - added by Carl Eugen Hoyos 2 years ago.

Change History (22)

by tudge, 2 years ago

Attachment: ffmpeg-20220813-222417.log added

full output

comment:1 by Carl Eugen Hoyos, 2 years ago

Please try to simplify the command line.

in reply to:  1 ; comment:2 by tudge, 2 years ago

Replying to Carl Eugen Hoyos:

Please try to simplify the command line.

sorry, but how simplification will help me?

in reply to:  2 ; comment:3 by Carl Eugen Hoyos, 2 years ago

Replying to tudge:

Replying to Carl Eugen Hoyos:

Please try to simplify the command line.

sorry, but how simplification will help me?

It will help us to understand (and hopefully fix) the issue more easily.

comment:4 by tudge, 2 years ago

Description: modified (diff)

in reply to:  3 comment:5 by tudge, 2 years ago

Replying to Carl Eugen Hoyos:

Replying to tudge:

Replying to Carl Eugen Hoyos:

Please try to simplify the command line.

sorry, but how simplification will help me?

It will help us to understand (and hopefully fix) the issue more easily.

Simplified it.

comment:6 by Carl Eugen Hoyos, 2 years ago

Keywords: crash added; subtitles removed

Are cuda and nvenc needed to reproduce? Or is the issue also reproducible with the software scaler and the mpeg2video encoder?

in reply to:  6 comment:7 by tudge, 2 years ago

Replying to Carl Eugen Hoyos:

Are cuda and nvenc needed to reproduce? Or is the issue also reproducible with the software scaler and the mpeg2video encoder?

Yes, it is reproducible by software h264/h265 encoders.

comment:8 by Carl Eugen Hoyos, 2 years ago

Please provide a simplified command line that does not use hardware encoders and no external encoders if possible.

in reply to:  8 comment:9 by tudge, 2 years ago

Replying to Carl Eugen Hoyos:

Please provide a simplified command line that does not use hardware encoders and no external encoders if possible.

it worked without scaling in 1 video profile with h264_nvenc encoder. FHD to FHD:

ffmpeg -i any.mkv -c:v h264_nvenc -b:v 5M -map v:0 -c:a aac -b:a 128k -ac 2 -map a:0 -c:s webvtt -map s:1 -f hls -hls_list_size 0 -hls_time 6 -master_pl_name master.m3u8 -var_stream_map "v:0,a:0,agroup:aud,name:English,language:en,default:YES,s:0,sgroup:subs,name:English,language:en,default:YES" /any/stream.m3u8

but subtitles is showing up only on iOS & hlsplayer with delay.

comment:10 by Carl Eugen Hoyos, 2 years ago

Do I understand correctly that the issue is only reproducible with nvenc?

in reply to:  10 comment:11 by tudge, 2 years ago

Replying to Carl Eugen Hoyos:

Do I understand correctly that the issue is only reproducible with nvenc?

It reproducible with any scaling in 2 or more resolutions.

comment:12 by Carl Eugen Hoyos, 2 years ago

If a command line exists that allows to reproduce the crash without using a hardware encoder please provide this command line.

in reply to:  12 comment:13 by tudge, 2 years ago

Replying to Carl Eugen Hoyos:

If a command line exists that allows to reproduce the crash without using a hardware encoder please provide this command line.

./ffmpeg \
-fix_sub_duration \
-i "any.mkv" \
-filter_complex \
"[0:v]yadif,split=4[v1][v2][v3][v4]; \
[v1]scale=w=1920:h=1080[v1out]; \
[v2]scale=w=1280:h=720[v2out]; \
[v3]scale=w=848:h=480[v3out]; \
[v4]scale=w=640:h=360[v4out]" \
-map [v1out] -c:v:0 libx264 -b:v:0 4M -maxrate:v:0 3M -minrate:v:0 3M -bufsize:v:0 6M -preset slow -crf 19 \
-map [v2out] -c:v:1 libx264 -b:v:1 3M -maxrate:v:1 3M -minrate:v:1 1M -bufsize:v:1 6M -preset slow -crf 19 \
-map [v3out] -c:v:2 libx264 -b:v:2 1M -maxrate:v:2 1M -minrate:v:2 1M -bufsize:v:2 2M -preset slow -crf 19 \
-map [v4out] -c:v:3 libx264 -b:v:3 500K -maxrate:v:3 500K -minrate:v:3 500K -bufsize:v:3 1M -preset slow -crf 19 \
-c:a aac \
-map a:0 -b:a:0 128k \
-map a:1 -b:a:1 128k \
-c:s webvtt \
-map s:1 \
-map s:2 \
-f hls \
-hls_time 6 \
-hls_list_size 0 \
-hls_playlist_type vod \
-hls_flags independent_segments \
-master_pl_name master.m3u8 \
-hls_segment_type mpegts \
-hls_segment_filename /any/chunk_%02d%v.ts \
-var_stream_map "a:0,agroup:aud,name:Russian,language:ru,default:YES a:1,agroup:aud,name:EN,language:English,default:NO v:0,name:1080p,agroup:aud,s:0,sgroup:subs,name:Russian,language:ru,default:YES v:1,name:720p,agroup:aud,s:1,sgroup:subs,name:EN,language:English,default:NO v:2,name:480p,agroup:aud v:3,name:360p,agroup:aud" /any/stream_%v.m3u8

comment:14 by Carl Eugen Hoyos, 2 years ago

Can you also reproduce the crash with the following command line?
./ffmpeg -i "any.mkv" -filter_complex "split[v1out][v2out]" -map [v1out] -map [v2out] -map s:1 -map s:2 -var_stream_map "v:0,s:0 v:1,s:1" /any/stream_%v.m3u8

comment:15 by Carl Eugen Hoyos, 2 years ago

Component: undeterminedavformat
Keywords: hls SIGSEGV regression added; webvtt removed

Looks like a regression since c64d56a2f53455f803456811873ff08fce98e122

in reply to:  14 ; comment:16 by tudge, 2 years ago

Replying to Carl Eugen Hoyos:

Can you also reproduce the crash with the following command line?
./ffmpeg -i "any.mkv" -filter_complex "split[v1out][v2out]" -map [v1out] -map [v2out] -map s:1 -map s:2 -var_stream_map "v:0,s:0 v:1,s:1" /any/stream_%v.m3u8

all the same. Core dumped.

UPD:

master build from MAY 2021 worked fine. Testing it.

Version 1, edited 2 years ago by tudge (previous) (next) (diff)

in reply to:  16 comment:17 by Carl Eugen Hoyos, 2 years ago

Replying to tudge:

Replying to Carl Eugen Hoyos:

Can you also reproduce the crash with the following command line?
./ffmpeg -i "any.mkv" -filter_complex "split[v1out][v2out]" -map [v1out] -map [v2out] -map s:1 -map s:2 -var_stream_map "v:0,s:0 v:1,s:1" /any/stream_%v.m3u8

all the same. Core dumped.

That's what I meant with a "simplified command line".

by Carl Eugen Hoyos, 2 years ago

Attachment: any.mkv added

comment:18 by Carl Eugen Hoyos, 2 years ago

Reproduced by developer: set
Status: newopen

Crashes for example with:

$ ffmpeg -i any.mkv  -map 0 -var_stream_map "v:0,s:0 v:1,s:1" -vcodec mpeg2video any/stream_%v.m3u8
$ ffmpeg -i any.mkv  -map 0 -var_stream_map "v:0,s:0 v:1,s:1" -vcodec copy any/stream_%v.m3u8
$ ffmpeg -i any.mkv  -map 0 -var_stream_map "v:0,s:0 v:1,s:1" any/stream_%v.m3u8
==217== Invalid read of size 8
==217==    at 0x81E2ED: ff_write_chained (mux.c:1365)
==217==    by 0x7A8C1B: hls_write_packet (hlsenc.c:2669)
==217==    by 0x81F206: write_packet (mux.c:728)
==217==    by 0x81EE61: interleaved_write_packet (mux.c:1102)
==217==    by 0x81EE61: write_packet_common (mux.c:1127)
==217==    by 0x81DD0E: av_interleaved_write_frame (mux.c:1243)
==217==    by 0x40B056: write_packet (ffmpeg_mux.c:174)
==217==    by 0x40A908: sync_queue_process (ffmpeg_mux.c:204)
==217==    by 0x40A908: muxer_thread (ffmpeg_mux.c:235)
==217==    by 0x57A36DA: start_thread (pthread_create.c:463)
==217==    by 0x5ADCA3E: clone (clone.S:95)
==217==  Address 0xd384068 is 8 bytes before a block of size 8 alloc'd
==217==    at 0x4C2FA3F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==217==    by 0x4C31D84: realloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==217==    by 0x84A18F: avformat_new_stream (options.c:250)
==217==    by 0x7AB19C: hls_mux_init (hlsenc.c:889)
==217==    by 0x7AB19C: hls_init (hlsenc.c:3084)
==217==    by 0x81CD66: init_muxer (mux.c:346)
==217==    by 0x81CD66: avformat_init_output (mux.c:433)
==217==    by 0x81D03E: avformat_write_header (mux.c:457)
==217==    by 0x409DD4: of_check_init (ffmpeg_mux.c:478)
==217==    by 0x427D3A: init_output_stream (ffmpeg.c:3292)
==217==    by 0x427D3A: init_output_stream_wrapper (ffmpeg.c:837)
==217==    by 0x428429: do_video_out (ffmpeg.c:1205)
==217==    by 0x4280BA: reap_filters (ffmpeg.c:1427)
==217==    by 0x4214EB: transcode_step (ffmpeg.c:0)
==217==    by 0x4214EB: transcode (ffmpeg.c:4077)
==217==    by 0x41F965: main (ffmpeg.c:4248)
==217==
==217== Invalid read of size 8
==217==    at 0x81E2F5: ff_write_chained (mux.c:1363)
==217==    by 0x7A8C1B: hls_write_packet (hlsenc.c:2669)
==217==    by 0x81F206: write_packet (mux.c:728)
==217==    by 0x81EE61: interleaved_write_packet (mux.c:1102)
==217==    by 0x81EE61: write_packet_common (mux.c:1127)
==217==    by 0x81DD0E: av_interleaved_write_frame (mux.c:1243)
==217==    by 0x40B056: write_packet (ffmpeg_mux.c:174)
==217==    by 0x40A908: sync_queue_process (ffmpeg_mux.c:204)
==217==    by 0x40A908: muxer_thread (ffmpeg_mux.c:235)
==217==    by 0x57A36DA: start_thread (pthread_create.c:463)
==217==    by 0x5ADCA3E: clone (clone.S:95)
==217==  Address 0x10 is not stack'd, malloc'd or (recently) free'd

comment:19 by tudge, 22 months ago

Is it going to be fixed?

comment:20 by Steven Liu, 2 months ago

Resolution: fixed
Status: openclosed

should be fixed by commit 817c6a6762696e6efee44ddc4e2d706922b880e0, Thanks BtbN

Note: See TracTickets for help on using tickets.