Skip to content

mp4-mux: Add HLG-compatible HDR signaling to MP4 recordings (experimental, incomplete) - #742

Draft
chriscoveries wants to merge 3 commits into
obs-rust:masterfrom
chriscoveries:draft/dolby-vision-dvvc-mux
Draft

chriscoveries wants to merge 3 commits into
obs-rust:masterfrom
chriscoveries:draft/dolby-vision-dvvc-mux

Conversation

@chriscoveries

@chriscoveries chriscoveries commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Draft, and incomplete. We're opening this so upstream PR CI can build and test it. Our own CI is in the repair shop: see our note on #699. The encoder half described below isn't written yet.

HLG-compatible HDR signaling: pipeline and MP4 box layout (illustration)

Problem

On a Mac, VideoToolbox can encode HEVC profile 8.4: a 10-bit HLG HDR picture (BT.2020) with dynamic HDR metadata in the bitstream. That's the same format an iPhone records. VideoToolbox also hands back a native 24-byte configuration record for it. The MP4 muxer only writes hvcC, so that record never reaches the file. Players that understand the profile then treat the recording as plain HEVC/HLG and ignore the dynamic metadata.

Fix (this PR)

  • Adds an optional obs_encoder_info.get_codec_metadata callback and an obs_encoder_get_codec_metadata() accessor. The encoder's native record is passed through as an opaque blob. It's kept separate from the Annex-B data in get_extra_data, and it's never synthesized.
  • mp4-mux writes the record verbatim as a dvvC box beside hvcC. This sits behind the experimental write_hlg_compatible_hdr_config muxer option. Without the option, or without a record, nothing changes.
  • The new struct field is appended at the end of obs_encoder_info, after upstream's request_keyframe, so it's ABI-safe: obs_register_encoder_s copies only the caller's struct size.
  • A cmocka test pins the box framing: a 32-bit big-endian size of payload + 8, the dvvC type, and a byte-for-byte payload. It's registered through tests.d.

The base picture stays standard HLG. A player that only knows HLG still shows it as HLG HDR. The box only lets players that understand the profile also use the dynamic metadata.

Evidence

Here is real ffprobe output for the box emitted by this C function, grafted into the hvc1 sample entry of a minimal HEVC MP4, next to the same file without it. The DOVI wording is ffprobe's own label for this record.

ffprobe without vs with the dvvC box

The box extracted back out of the grafted file is byte-identical to the one the function emitted. Without the graft, ffprobe reports no configuration record.

Not done (why this is a draft)

  • No encoder implements get_codec_metadata yet. plugins/mac-videotoolbox/encoder.c doesn't fill it in, so a real OBS recording won't carry the box yet. The next step is reading the record from the encoder's format description.
  • There's no UI for the option, only the custom muxer option.
  • This was rebased onto current master without a full local build, and the cmocka test wasn't run after the rebase. We're relying on PR CI.
  • Licensing: we haven't established whether writing this record raises any licensing question for a GPL project. We'd welcome maintainers' view before this goes further.
  • Fork CI: not run. Our self-hosted CI is in the repair shop, so this relies on upstream PR CI.

Compatibility & risk

  • Opt-in only. Default recordings don't change.
  • One new exported function. It's declared EXPORT in obs.h, like the neighbouring obs_encoder_get_extra_data, so the Rust export lists don't change.

Thank you to the obs-rust maintainers and contributors for building this project in the open. In the American spirit of free expression and individual independence, and with the principle of judging contributions on their merit alone, this PR is a small piece of what independent people can build when they come together.

@chriscoveries chriscoveries changed the title mp4-mux: Write the Dolby Vision dvvC box (experimental, incomplete) mp4-mux: Write the dvvC configuration box for HLG HDR recordings (experimental, incomplete) Oct 14, 2026
@chriscoveries chriscoveries changed the title mp4-mux: Write the dvvC configuration box for HLG HDR recordings (experimental, incomplete) mp4-mux: Add HLG-compatible HDR signaling to MP4 recordings (experimental, incomplete) Oct 14, 2026
chriscoveries and others added 3 commits October 14, 2026 19:06
Add an optional encoder codec-metadata callback and an opt-in mux flag that writes a native Dolby Vision dvvC record beside hvcC. Cover the box framing and verbatim payload with a cmocka test.

DRAFT: No encoder, including mac-videotoolbox, implements the callback yet, so enabling write_dolby_vision cannot currently emit a dvvC box.
Rename the experimental muxer option to write_hlg_compatible_hdr_config and the flag to MP4_WRITE_HLG_COMPATIBLE_HDR_CONFIG, and describe the box by what it is compatible with. No behaviour change.
mp4-mux.c needs rtmp-av1.c/rtmp-hevc.c (obs_parse_*) and an
obs_module_text stub; the Tier 2 link failed without them.
@zackees

zackees commented Oct 15, 2026

Copy link
Copy Markdown
Member

Maintainer rebase onto master, replacing head 536432b3b, plus one fix commit:

  • test_mp4_mux_dvvc compiled mp4-mux.c alone, so linking failed: obs_parse_av1_packet, obs_parse_hevc_header, obs_parse_av1_header and obs_module_text were undefined. The test now builds rtmp-av1.c/rtmp-hevc.c too and stubs obs_module_text, as test_mp4_mux_multichannel does.
  • I applied the gersemi formatting.

Locally, ./lint passes and Tier 2 Linux is 231/231 OFF and ON with symbols IDENTICAL. I left it as a draft, since the description says the encoder half isn't written yet.

@zackees
zackees force-pushed the draft/dolby-vision-dvvc-mux branch from 536432b to 72c48c4 Compare October 15, 2026 02:18
@zackees

zackees commented Oct 16, 2026

Copy link
Copy Markdown
Member

Review from the maintainer side. I read the body, the comments and the diff (head 72c48c4ec) and checked CI. I did not build it myself.

What I checked. mp4_write_hvc1 computes the sample entry size with write_box_size, so adding a dvvC child box inside it keeps the sizes right. Default behaviour is unchanged: nothing is written unless write_hlg_compatible_hdr_config is set and the encoder returns a record. CI: 17 pass, 5 skipped, 0 failing, and the branch merges cleanly (no rebase needed).

Gaps.

  1. Only the box framing is tested (test_mp4_mux_dvvc). Nothing tests that mp4_write_hvc1 writes the box with the flag on, and does not with it off or when get_codec_metadata returns false. That integration is the actual behaviour change.
  2. No encoder implements get_codec_metadata, so no real recording carries the box, and this PR's change cannot be shown end to end. The ffprobe evidence comes from grafting the box into a synthetic file.
  3. obs_encoder_get_codec_metadata returns true for an encoder that reports true with size 0 or a NULL pointer; the muxer would then write an empty box. A guard is cheap.
  4. The commits are not RED then GREEN (the test and the feature land together in 9c9a95b1f).
  5. Time of availability: the record from VideoToolbox may only exist after the first frame. Please say when the muxer reads it relative to encoder start (the same question get_extra_data has).

Why this one needs a maintainer decision (c). Two questions are not mine to answer here, so I am leaving it as a draft and taking them to the repo owner:

  • It adds a field to the public struct obs_encoder_info and a new exported function in obs.h. Our rule is no edits to public C headers; this is an addition, but it extends the libobs C API/ABI, so it needs an explicit yes or no.
  • Your own open question on licensing for writing this record, and whether we want Dolby-branded signaling at all.

I'll post the answer here once there is one. No change is needed from you until then.

@zackees

zackees commented Oct 25, 2026

Copy link
Copy Markdown
Member

Coordinator check-in, @chriscoveries: there's been no activity here since the maintainer's review about 9 days ago. Are you still working on this? If you've moved on, say "handed off to the coordinator" and I'll keep the mechanical work (rebases, list conflicts, formatting) moving. Anything in the review that needs a design change stays with you.

@zackees

zackees commented Oct 27, 2026

Copy link
Copy Markdown
Member

Status from the coordinator, @chriscoveries — this draft is now DIRTY (conflicting), and the reason is mechanical rather than your design: master renamed this file out from under the PR.

  • plugins/obs-outputs/mp4-mux.c no longer exists on master; it is plugins/obs-outputs/mp4-mux.c.h after 6940520a8 ("obs-outputs: Rename sources to implementation files"). Every other file the PR touches still resolves, so git merge-tree origin/master pull/742/head reports exactly one conflict, mp4-mux.c.h.
  • The fix is to rebase onto origin/master and re-apply your hunks onto mp4-mux.c.h. That is a rename follow, not a redesign, so I can do it for you as a fixup: commit and push with --force-with-lease — say the word, or handed off to the coordinator if you would rather I own the mechanical part outright.

Two other things, since the head here is 72c48c4ec (2026-10-15 — the maintainer's test-wiring commit; your own last change is older):

  1. This is still a draft marked experimental/incomplete. If the HLG signalling is not something you are going to finish, say so and I will report it to the maintainer rather than leave it looking active.
  2. If you do want it to land, the merge gate needs a docs/features.md line (a user-visible MP4 HDR change) — note that file does not exist on this branch at all, it was added on master after your base, so the line has to be carried in from master — plus a RED test on master. You already have test/cmocka/test_mp4_mux_dvvc.c, so it is mostly the ledger line and a rebased GREEN.

I am not taking the code fix over while it is a design-in-progress; the rebase is the only part that is mine to do.

@chriscoveries

Copy link
Copy Markdown
Contributor Author

handed off to the coordinator. Sorry for going quiet; life has gotten in the way of keeping up with these. I'm not going to finish the HLG signalling design, so please report it to the maintainer as you offered. The rebase is yours if it's still wanted.

@obs-rust-project-manager obs-rust-project-manager Bot moved this from Needs fix to In progress in obs-rust Multiview Nov 1, 2026
@obs-rust-project-manager obs-rust-project-manager Bot moved this from In progress to Needs fix in obs-rust Multiview Nov 1, 2026
@obs-rust-project-manager obs-rust-project-manager Bot moved this from Needs fix to Stalled in obs-rust Multiview Nov 3, 2026
@obs-rust-project-manager obs-rust-project-manager Bot moved this from Stalled to Needs fix in obs-rust Multiview Nov 4, 2026
@obs-rust-project-manager obs-rust-project-manager Bot moved this from Needs fix to Stalled in obs-rust Multiview Nov 5, 2026
@obs-rust-project-manager obs-rust-project-manager Bot moved this from Stalled to Needs fix in obs-rust Multiview Nov 6, 2026
@obs-rust-project-manager obs-rust-project-manager Bot moved this from Needs fix to Stalled in obs-rust Multiview Nov 6, 2026
@obs-rust-project-manager obs-rust-project-manager Bot moved this from Stalled to Needs fix in obs-rust Multiview Nov 7, 2026
@obs-rust-project-manager obs-rust-project-manager Bot moved this from Needs fix to Stalled in obs-rust Multiview Nov 21, 2026
@obs-rust-project-manager obs-rust-project-manager Bot moved this from Stalled to Needs fix in obs-rust Multiview Nov 21, 2026
@obs-rust-project-manager obs-rust-project-manager Bot moved this from Needs fix to Stalled in obs-rust Multiview Nov 25, 2026
@obs-rust-project-manager obs-rust-project-manager Bot moved this from Stalled to Needs fix in obs-rust Multiview Nov 25, 2026
@obs-rust-project-manager obs-rust-project-manager Bot moved this from Needs fix to Stalled in obs-rust Multiview Nov 26, 2026
@obs-rust-project-manager obs-rust-project-manager Bot moved this from Stalled to Needs fix in obs-rust Multiview Nov 27, 2026
@obs-rust-project-manager obs-rust-project-manager Bot moved this from Needs fix to Stalled in obs-rust Multiview Nov 29, 2026
@obs-rust-project-manager obs-rust-project-manager Bot moved this from Stalled to Needs fix in obs-rust Multiview Nov 29, 2026
@obs-rust-project-manager obs-rust-project-manager Bot moved this from Needs fix to Stalled in obs-rust Multiview Nov 30, 2026
@obs-rust-project-manager obs-rust-project-manager Bot moved this from Stalled to Needs fix in obs-rust Multiview Nov 30, 2026
@obs-rust-project-manager obs-rust-project-manager Bot moved this from Needs fix to Stalled in obs-rust Multiview Dec 5, 2026
@zackees

zackees commented Dec 5, 2026

Copy link
Copy Markdown
Member

Rebase status (coordinator pass, 2026-12-04), for whoever picks this up after the hand-off: a test merge onto current master conflicts in two places.

  • libobs/obs-encoder.c no longer exists: master renamed it and then split it into many libobs/obs-encoder-*.c.h units (plus obs-encoder.c.h), several of them ported to Rust. The hunks need to be re-applied to whichever unit now holds that code.
  • plugins/obs-outputs/mp4-mux.c.h: content conflict with later master edits.

This PR also changes the public headers libobs/obs.h and libobs/obs-encoder.h, which a port must not do, so landing it would need an explicit maintainer decision on the API. Left open as a parked experiment; nothing here is superseded on master.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Stalled

Development

Successfully merging this pull request may close these issues.

2 participants