From af47e93b97a3d33e6a6da6a2651269567cf8701d Mon Sep 17 00:00:00 2001 From: Vivia Nikolaidou Date: Fri, 27 Jan 2017 16:14:16 +0200 Subject: [PATCH] qtmux: Timecode track fixes for STSD entry The n_frames field (frames per second) should follow the nominal frame rate for drop-frame timecodes. Also, the trak's timescale (and duration, accordingly) should follow the STSD entry's timescale and frame duration (fps_n and fps_d accordingly), not the other way around. https://bugzilla.gnome.org/show_bug.cgi?id=777832 --- gst/isomp4/atoms.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/gst/isomp4/atoms.c b/gst/isomp4/atoms.c index 101f12d..64c121f 100644 --- a/gst/isomp4/atoms.c +++ b/gst/isomp4/atoms.c @@ -3192,23 +3192,24 @@ timecode_atom_trak_set_duration (AtomTRAK * trak, guint64 duration, g_assert (trak->mdia.minf.gmhd != NULL); g_assert (atom_array_get_len (&trak->mdia.minf.stbl.stts.entries) == 1); - trak->tkhd.duration = duration; - trak->mdia.mdhd.time_info.duration = duration; - trak->mdia.mdhd.time_info.timescale = timescale; - - entry = &atom_array_index (&trak->mdia.minf.stbl.stts.entries, 0); - entry->sample_delta = duration; - for (iter = trak->mdia.minf.stbl.stsd.entries; iter; iter = g_list_next (iter)) { SampleTableEntry *entry = iter->data; if (entry->kind == TIMECODE) { SampleTableEntryTMCD *tmcd = (SampleTableEntryTMCD *) entry; - tmcd->frame_duration = tmcd->frame_duration * timescale / tmcd->timescale; - tmcd->timescale = timescale; + duration = duration * tmcd->timescale / timescale; + timescale = tmcd->timescale; + break; } } + + trak->tkhd.duration = duration; + trak->mdia.mdhd.time_info.duration = duration; + trak->mdia.mdhd.time_info.timescale = timescale; + + entry = &atom_array_index (&trak->mdia.minf.stbl.stts.entries, 0); + entry->sample_delta = duration; } static guint32 @@ -3779,7 +3780,10 @@ atom_trak_add_timecode_entry (AtomTRAK * trak, AtomsContext * context, tmcd->name.name = g_strdup ("Tape"); tmcd->timescale = tc->config.fps_n; tmcd->frame_duration = tc->config.fps_d; - tmcd->n_frames = tc->config.fps_n / tc->config.fps_d; + if (tc->config.fps_d == 1001) + tmcd->n_frames = tc->config.fps_n / 1000; + else + tmcd->n_frames = tc->config.fps_n / tc->config.fps_d; stsd->entries = g_list_prepend (stsd->entries, tmcd); stsd->n_entries++; -- 2.7.4