Skip to content

mp4: header creation/modification timestamps, read and write - #8

Open
jayhf wants to merge 1 commit into
OxideAV:masterfrom
jayhf:jf/header-timestamps
Open

mp4: header creation/modification timestamps, read and write#8
jayhf wants to merge 1 commit into
OxideAV:masterfrom
jayhf:jf/header-timestamps

Conversation

@jayhf

@jayhf jayhf commented Aug 14, 2026

Copy link
Copy Markdown

Adds read and write support for the ISO/IEC 14496-12 header timestamps (mvhd §8.2.2, tkhd §8.3.2, mdhd §8.4.2), which the muxer previously hardcoded to zero and the demuxer skipped past. All values are in the header epoch, seconds since 1904-01-01 UTC, on both sides — no conversion on intake, so a value read off a file feeds straight back into the muxer.

  • Mp4MuxerOptions::creation_time / modification_time stamp all three boxes; track_header_timestamps overrides tkhd/mdhd per stream, with a per-entry media override for a source that dates its media apart from the track carrying it. An entry replaces the pair it names rather than inheriting either half.
  • Mp4Demuxer::mvhd_timestamps() / tkhd_timestamps(stream) / mdhd_timestamps(stream) return the new demux::HeaderTimestamps, mirrored on the flat metadata channel as mvhd_* / tkhd_* / mdhd_* keys, emitted only when non-zero.
  • Epoch helpers mp4_secs_from_unix_secs / mp4_secs_from_system_time / unix_secs_from_mp4_secs plus MP4_EPOCH_OFFSET_SECS.
  • A timestamp past 2040-02-06 in either half promotes its box from version 0 to version 1, per box and automatic.
  • Every field the demuxer can report is independently writable. Default output stays byte-identical to before.

15 integration tests, including a byte-patched fixture putting six distinct values in the six fields, and a PATH-gated cross-check that reads back a stamp written by ffmpeg. Note the ffmpeg check skips on CI, since the crate-ci shim installs no extra packages.

@jayhf
jayhf marked this pull request as ready for review August 14, 2026 20:55
@jayhf

jayhf commented Aug 18, 2026

Copy link
Copy Markdown
Author

@MagicalTux can you please review this?

@jayhf
jayhf force-pushed the jf/header-timestamps branch from 7714ffd to 1013ace Compare August 25, 2026 19:05
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.

1 participant