From e97b50af51b9e607ef48882bc1c813b9fd2cc3bc Mon Sep 17 00:00:00 2001 From: Jan Schmidt Date: Sun, 19 Jul 2015 01:48:35 +1000 Subject: [PATCH] rpicamsrc: Fix buffer PTS calculation Timestamps from MMAL are in microseconds, so make sure to convert to nanoseconds before using them to adjust the GStreamer buffer time --- sys/rpicamsrc/RaspiCapture.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/sys/rpicamsrc/RaspiCapture.c b/sys/rpicamsrc/RaspiCapture.c index 2c18a82425..abe5346cd7 100644 --- a/sys/rpicamsrc/RaspiCapture.c +++ b/sys/rpicamsrc/RaspiCapture.c @@ -951,13 +951,15 @@ raspi_capture_fill_buffer(RASPIVID_STATE *state, GstBuffer **bufp, mmal_port_parameter_get(state->encoder_output_port, ¶m.hdr); if (param.value != -1 && param.value >= buffer->pts) { - GstClockTime offset = param.value - buffer->pts; + /* Convert microsecond RPi TS to GStreamer clock: */ + GstClockTime offset = (param.value - buffer->pts) * 1000; if (runtime >= offset) gst_pts = runtime - offset; } - GST_LOG ("Buf PTS %" G_GINT64_FORMAT " DTS %" G_GINT64_FORMAT - " STC %" G_GINT64_FORMAT " TS %" GST_TIME_FORMAT, - buffer->pts, buffer->dts, param.value, + GST_LOG ("Buf (uS) PTS %" G_GINT64_FORMAT " DTS %" G_GINT64_FORMAT + " STC %" G_GINT64_FORMAT " (latency %" G_GINT64_FORMAT + "uS) TS %" GST_TIME_FORMAT, + buffer->pts, buffer->dts, param.value, param.value - buffer->pts, GST_TIME_ARGS (gst_pts)); }