[0.11] gst-plugins-good: flvmux: properly determine final duration

Sebastian Dröge slomo at kemper.freedesktop.org
Tue Jan 10 05:33:25 PST 2012


Module: gst-plugins-good
Branch: 0.11
Commit: b175d1cbc491b33ad8b11a8a4098c0a5d1cacacd
URL:    http://cgit.freedesktop.org/gstreamer/gst-plugins-good/commit/?id=b175d1cbc491b33ad8b11a8a4098c0a5d1cacacd

Author: Mark Nauwelaerts <mark.nauwelaerts at collabora.co.uk>
Date:   Fri Dec 16 19:15:38 2011 +0100

flvmux: properly determine final duration

... which can be authoratively obtained from our own written timestamps.

---

 gst/flv/gstflvmux.c |   16 +++++++---------
 1 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/gst/flv/gstflvmux.c b/gst/flv/gstflvmux.c
index 4a8b18f..c7ee0a8 100644
--- a/gst/flv/gstflvmux.c
+++ b/gst/flv/gstflvmux.c
@@ -1250,12 +1250,6 @@ gst_flv_mux_determine_duration (GstFlvMux * mux)
     }
   }
 
-  if (duration == GST_CLOCK_TIME_NONE) {
-    GST_DEBUG_OBJECT (mux, "not able to determine duration "
-        "from pad timestamps, assuming 0");
-    return 0;
-  }
-
   return duration;
 }
 
@@ -1269,6 +1263,7 @@ gst_flv_mux_rewrite_header (GstFlvMux * mux)
   GList *l;
   guint32 index_len, allocate_size;
   guint32 i, index_skip;
+  GstClockTime dur;
 
   if (mux->streamable)
     return GST_FLOW_OK;
@@ -1281,9 +1276,12 @@ gst_flv_mux_rewrite_header (GstFlvMux * mux)
     return GST_FLOW_OK;
   }
 
-  /* if we were not able to determine the duration before, set it now */
-  if (mux->duration == GST_CLOCK_TIME_NONE)
-    mux->duration = gst_flv_mux_determine_duration (mux);
+  /* determine duration now based on our own timestamping,
+   * so that it is likely many times better and consistent
+   * than whatever obtained by some query */
+  dur = gst_flv_mux_determine_duration (mux);
+  if (dur != GST_CLOCK_TIME_NONE)
+    mux->duration = dur;
 
   /* rewrite the duration tag */
   d = gst_guint64_to_gdouble (mux->duration);



More information about the gstreamer-commits mailing list