From 94f8603411d607aa125f31d48786c8bbf10eab25 Mon Sep 17 00:00:00 2001 From: Vivia Nikolaidou Date: Wed, 12 Sep 2018 17:24:00 +0300 Subject: [PATCH] qtmux: Allow up to 1 trak timescale unit of lateness in prefill mode For 59.94 FPS, it's common to set 60000 as timescale. For that timescale, if the audio is late by as little as 0:00:00.000016666 (definitely less than one audio sample), lateness gets rounded to 1. Added a safeguard that allows lateness up to 1 sample with the specific trak's timescale, to make sure that values less than e.g. one audio sample won't break the prefill mode. What will happen in this case is that the audio will get squeezed back to the video's timestamp, which in practice means that the audio will be 0.000016666 seconds early (with the patch). https://bugzilla.gnome.org/show_bug.cgi?id=797133 --- gst/isomp4/gstqtmux.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/gst/isomp4/gstqtmux.c b/gst/isomp4/gstqtmux.c index fafd94b..97591de 100644 --- a/gst/isomp4/gstqtmux.c +++ b/gst/isomp4/gstqtmux.c @@ -3454,13 +3454,18 @@ gst_qt_mux_update_edit_lists (GstQTMux * qtmux) has_gap = (qtpad->first_ts > (qtmux->first_ts + qtpad->dts_adjustment)); if (has_gap) { - GstClockTime diff; + GstClockTime diff, trak_lateness; diff = qtpad->first_ts - (qtmux->first_ts + qtpad->dts_adjustment); lateness = gst_util_uint64_scale_round (diff, qtmux->timescale, GST_SECOND); + /* Allow up to 1 trak timescale unit of lateness, Such a small + * timestamp/duration can't be represented by the trak-specific parts + * of the headers anyway, so it's irrelevantly small */ + trak_lateness = gst_util_uint64_scale (diff, + atom_trak_get_timescale (qtpad->trak), GST_SECOND); - if (lateness > 0) { + if (lateness > 0 && trak_lateness > 0) { GST_DEBUG_OBJECT (qtmux, "Pad %s is a late stream by %" GST_TIME_FORMAT, GST_PAD_NAME (qtpad->collect.pad), GST_TIME_ARGS (diff)); -- 2.7.4