From 6b889bea696ccf4f65d3d399c6522f49b3aabe80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Tue, 4 Apr 2017 15:08:33 +0300 Subject: [PATCH] qtmux: Select the best pad based on the cached last_buf if any last_buf is the one we're going to write next, not buf. As such we should check timestamps against that one if there is one to select the earliest pad. Also remember the currently selected pad in the very beginning when storing the first last_buf. This both solves some edge cases where not the correct next pad was selected corresponding to the target interleave. --- gst/isomp4/gstqtmux.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gst/isomp4/gstqtmux.c b/gst/isomp4/gstqtmux.c index cf5c3bf8c6..82852f9122 100644 --- a/gst/isomp4/gstqtmux.c +++ b/gst/isomp4/gstqtmux.c @@ -3234,6 +3234,7 @@ gst_qt_mux_add_buffer (GstQTMux * qtmux, GstQTPad * pad, GstBuffer * buf) } #endif pad->last_buf = buf; + qtmux->current_pad = pad; goto exit; } else { gst_buffer_ref (last_buf); @@ -3600,7 +3601,10 @@ find_best_pad (GstQTMux * qtmux, GstCollectPads * pads) continue; } } else { - timestamp = GST_BUFFER_DTS_OR_PTS (tmp_buf); + if (qtpad->last_buf) + timestamp = GST_BUFFER_DTS_OR_PTS (qtpad->last_buf); + else + timestamp = GST_BUFFER_DTS_OR_PTS (tmp_buf); } if (best_pad == NULL ||