mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-22 15:18:21 +00:00
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.
This commit is contained in:
parent
23b093dee3
commit
45f711044f
2 changed files with 7 additions and 2 deletions
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue