Bug 2073980

Summary: ffmpeg crashes when muxing H.264 video and AAC audio stream into MP4 container
Product: [Fedora] Fedora Reporter: Dominik 'Rathann' Mierzejewski <dominik>
Component: ffmpegAssignee: Neal Gompa <ngompa13>
Status: CLOSED ERRATA QA Contact:
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 36CC: asn, dominik, fzatlouk, kirill.lavroff, ngompa13
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard: AcceptedFreezeException
Fixed In Version: ffmpeg-5.0.1-1.fc36 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-04-14 23:23:58 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1953786    

Description Dominik 'Rathann' Mierzejewski 2022-04-11 09:30:26 UTC
Description of problem:
yt-dlp can download video and audio as separate streams and combine (mux) them automatically using ffmpeg. It seems that ffmpeg is crashing when muxing H.264 and AAC streams into MP4 container. The RPM Fusion one works correctly.

Version-Release number of selected component (if applicable):
ffmpeg-free-5.0-9.fc36.x86_64

How reproducible:
Always

Steps to Reproduce:
1. yt-dlp -f 299+140 https://www.youtube.com/watch?v=G5RpJwCJDqc

Or directly:

1. ffmpeg -i "Japan in 8K ULTRA HD - Land of The Rising Sun (60 FPS) [G5RpJwCJDqc].f299.mp4" -i "Japan in 8K ULTRA HD - Land of The Rising Sun (60 FPS) [G5RpJwCJDqc].f140.m4a" -c:v copy -c:a copy "Japan in 8K ULTRA HD - Land of The Rising Sun (60 FPS) [G5RpJwCJDqc].1080p.mp4"

Actual results:
Segmentation fault (core dumped)

Expected results:
Successful muxing without crash.

Additional info:
RPM Fusion build works.

Comment 1 Dominik 'Rathann' Mierzejewski 2022-04-11 10:13:11 UTC
...
Core was generated by `ffmpeg -i Japan in 8K ULTRA HD - Land of The Rising Sun (60 FPS) [G5RpJwCJDqc].'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x00007feb39c1ccf6 in parse_nal_units (buf_size=<optimized out>, buf=<optimized out>, avctx=<optimized out>, s=0x55ec723a08c0) at libavcodec/h264_parser.c:559
559	                    h->x264_build = p->sei.unregistered.x264_build;
(gdb) where
#0  0x00007feb39c1ccf6 in parse_nal_units (buf_size=<optimized out>, buf=<optimized out>, avctx=<optimized out>, s=0x55ec723a08c0) at libavcodec/h264_parser.c:559
#1  h264_parse (s=0x55ec723a08c0, avctx=<optimized out>, poutbuf=0x55ec7239c398, poutbuf_size=0x55ec7239c3a0, buf=<optimized out>, buf_size=<optimized out>) at libavcodec/h264_parser.c:616
#2  0x00007feb39ceff19 in av_parser_parse2 (s=0x55ec723a08c0, avctx=0x55ec7239d540, poutbuf=poutbuf@entry=0x55ec7239c398, poutbuf_size=poutbuf_size@entry=0x55ec7239c3a0, buf=<optimized out>, 
    buf@entry=0x7feb316ae040 "", buf_size=buf_size@entry=143211, pts=0, dts=-256, pos=5302) at libavcodec/parser.c:165
#3  0x00007feb3a200aa0 in parse_packet (s=s@entry=0x55ec7239bf80, pkt=pkt@entry=0x55ec7239c280, stream_index=<optimized out>, flush=flush@entry=0) at libavformat/demux.c:1126
#4  0x00007feb3a209cc3 in read_frame_internal (s=s@entry=0x55ec7239bf80, pkt=pkt@entry=0x55ec7239c280) at libavformat/demux.c:1320
#5  0x00007feb3a20af61 in avformat_find_stream_info (ic=0x55ec7239bf80, options=options@entry=0x55ec723a0880) at libavformat/demux.c:2584
#6  0x000055ec70f755df in open_input_file (o=o@entry=0x7ffc67921160, filename=<optimized out>) at fftools/ffmpeg_opt.c:1200
#7  0x000055ec70f83d2c in open_files (l=0x55ec7239be18, inout=inout@entry=0x55ec70f9bacc "input", open_file=0x55ec70f748d0 <open_input_file>) at fftools/ffmpeg_opt.c:3423
#8  0x000055ec70f874d3 in ffmpeg_parse_options (argc=10, argv=0x7ffc679218c8) at fftools/ffmpeg_opt.c:3463
#9  0x000055ec70f70fbe in main (argc=10, argv=0x7ffc679218c8) at fftools/ffmpeg.c:4872
(gdb)

Comment 2 Dominik 'Rathann' Mierzejewski 2022-04-11 10:33:28 UTC
The crash seems to be due:
(gdb) display h->x264_build
1: h->x264_build = <error: Cannot access memory at address 0x55ec724576b0>

Comment 3 Dominik 'Rathann' Mierzejewski 2022-04-11 10:41:11 UTC
Looks like it's fixed in 5.0.1:

https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/3c804fdd4a37a7130a85e38ab67daa38bb8c1d35

Comment 4 Fedora Blocker Bugs Application 2022-04-13 01:24:52 UTC
Proposed as a Freeze Exception for 36-final by Fedora user ngompa using the blocker tracking app because:

 It'd be good to have our MP4+H.264+AAC functionality working out of the box when using ffmpeg, especially for applications that demux and remux streams like some tools do.

Comment 5 Fedora Update System 2022-04-13 01:46:25 UTC
FEDORA-2022-3e9af2f9bd has been submitted as an update to Fedora 36. https://bodhi.fedoraproject.org/updates/FEDORA-2022-3e9af2f9bd

Comment 6 FrantiĊĦek Zatloukal 2022-04-13 14:32:50 UTC
Discussed in ticket: https://pagure.io/fedora-qa/blocker-review/issue/748

The decision to classify this bug as an AcceptedFreezeException was made:

"This issue was determined to be significant enough to warrant a FreezeException."

Comment 7 Fedora Update System 2022-04-14 23:23:58 UTC
FEDORA-2022-3e9af2f9bd has been pushed to the Fedora 36 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 8 Neal Gompa 2022-04-15 12:19:05 UTC
*** Bug 2075800 has been marked as a duplicate of this bug. ***