Skip to content

H264/MP4 Mux/Demux Fixes - #218

Merged
nickgaray merged 10 commits into
opensensorhub:masterfrom
Botts-Innovative-Research:mp4-mux-fixes
Jul 24, 2026
Merged

H264/MP4 Mux/Demux Fixes#218
nickgaray merged 10 commits into
opensensorhub:masterfrom
Botts-Innovative-Research:mp4-mux-fixes

Conversation

@kyle-fitzp

Copy link
Copy Markdown
Contributor
  1. Comment-out a line of debug code that prevents the SOS MP4 Serializer from working.
  2. Simplify the FFmpeg H264 & H265/HEVC logic for the Inject Extradata config setting.

FFmpeg driver now no longer manually converts and inserts extradata on each key frame. Instead, it relies on FFmpeg's bitstream filters.

  1. Code in StreamContext is more readable, as it's no longer mixing in bitwise logic with stream management.
  2. This fixes MP4 files that already had AVCC extradata inserted on each keyframe. The previous implementation would not replace AVCC extradata that was already in the stream, instead simply converting AVCC extradata to Annex B and naively prepending each keyframe with the converted extradata. This could lead to cases where some streams would have both AVCC and Annex B extradata on each keyframe, making the stream unparseable. The new implementation with the FFmpeg bitstream filter will correctly convert all extradata, even that which is already inserted before each keyframe.

@kyle-fitzp kyle-fitzp linked an issue Jun 18, 2026 that may be closed by this pull request

@Cardy2 Cardy2 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll just re-add what I messaged you about here:

I re-tested it and everything works. I dont think they're blockers but just curious if we should document 2 things:

1.) We intentionally drop the SEI in filtering pass_types=1|5  - if we need that metadata in the future we should add 6?
2.) Parameter-set injection relies on demuxer keyframe flags: AV_PKT_FLAG_KEY is assumed to be correctly given from the source otherwise the parameter sets will not be reinjected by dump_extra

Those things might be obvious but I just wanted to see if you had thought about them?

Otherwise, good to go.

@nickgaray
nickgaray merged commit 61749e1 into opensensorhub:master Jul 24, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix FFmpeg Driver H264/H265

3 participants