Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

obs-outputs: Fix tkhd/mvhd box version with 64-bit timestamps #11682

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions plugins/obs-outputs/mp4-mux.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,12 @@ static size_t mp4_write_mvhd(struct mp4_mux *mux)
break;
}
}
bool extended_ts = duration > UINT32_MAX || mux->creation_time > UINT32_MAX;
uint8_t version = extended_ts ? 1 : 0;

write_fullbox(s, 0, "mvhd", 0, 0);
write_fullbox(s, 0, "mvhd", version, 0);

if (duration > UINT32_MAX || mux->creation_time > UINT32_MAX) {
if (extended_ts) {
s_wb64(s, mux->creation_time); // creation time
s_wb64(s, mux->creation_time); // modification time
s_wb32(s, 1000); // timescale
Expand Down Expand Up @@ -203,12 +205,14 @@ static size_t mp4_write_tkhd(struct mp4_mux *mux, struct mp4_track *track)
size_t start = serializer_get_pos(s);

uint64_t duration = util_mul_div64(track->duration, 1000, track->timebase_den);
bool extended_ts = duration > UINT32_MAX || mux->creation_time > UINT32_MAX;
uint8_t version = extended_ts ? 1 : 0;

/* Flags are 0x1 (enabled) | 0x2 (in movie) */
static const uint32_t flags = 0x1 | 0x2;
write_fullbox(s, 0, "tkhd", 0, flags);
write_fullbox(s, 0, "tkhd", version, flags);

if (duration > UINT32_MAX || mux->creation_time > UINT32_MAX) {
if (extended_ts) {
s_wb64(s, mux->creation_time); // creation time
s_wb64(s, mux->creation_time); // modification time
s_wb32(s, track->track_id); // track_id
Expand Down
Loading