diff options
author | Zaheer Abbas Merali <zaheerabbas@merali.org> | 2010-06-09 22:00:16 +0200 |
---|---|---|
committer | Zaheer Abbas Merali <zaheerabbas@merali.org> | 2010-06-10 01:32:15 +0200 |
commit | 45f711044fe60efba33e0dbaba354860fd450eed (patch) | |
tree | 3a0845df1c97b7650e4e3fa800a6dd8fc59647c1 | |
parent | 23b093dee3b22526de5deb7069d4c37ba447db26 (diff) |
matroskamux: change 2 second limit per cluster
Start cluster at every keyframe or when we would overflow the previous
cluster's relative timestamp field. This would avoid as much as possible
starting clusters at non-keyframes.
-rw-r--r-- | gst/matroska/matroska-mux.c | 7 | ||||
-rw-r--r-- | gst/matroska/matroska-mux.h | 2 |
2 files changed, 7 insertions, 2 deletions
diff --git a/gst/matroska/matroska-mux.c b/gst/matroska/matroska-mux.c index 0ed36fcc0..265eb186d 100644 --- a/gst/matroska/matroska-mux.c +++ b/gst/matroska/matroska-mux.c @@ -546,6 +546,7 @@ gst_matroska_mux_reset (GstElement * element) /* reset timers */ mux->time_scale = GST_MSECOND; + mux->max_cluster_duration = G_MAXINT16 * mux->time_scale; mux->duration = 0; /* reset cluster */ @@ -2566,8 +2567,10 @@ gst_matroska_mux_write_data (GstMatroskaMux * mux, GstMatroskaPad * collect_pad) } if (mux->cluster) { - /* start a new cluster every two seconds or at keyframe */ - if (mux->cluster_time + GST_SECOND * 2 < GST_BUFFER_TIMESTAMP (buf) + /* start a new cluster at every keyframe or when we may be reaching the + * limit of the relative timestamp */ + if (mux->cluster_time + + mux->max_cluster_duration < GST_BUFFER_TIMESTAMP (buf) || is_video_keyframe) { if (!mux->streamable) gst_ebml_write_master_finish (ebml, mux->cluster); diff --git a/gst/matroska/matroska-mux.h b/gst/matroska/matroska-mux.h index 249f0c214..12700724a 100644 --- a/gst/matroska/matroska-mux.h +++ b/gst/matroska/matroska-mux.h @@ -102,6 +102,8 @@ typedef struct _GstMatroskaMux { /* timescale in the file */ guint64 time_scale; + /* based on timescale, limit of nanoseconds you can have in a cluster */ + guint64 max_cluster_duration; /* length, position (time, ns) */ guint64 duration; |