From beb537d10b281fb37ab8b8f7262b3fb2eec9b356 Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Thu, 22 Aug 2013 11:17:26 -0400 Subject: [PATCH] transcoding: Print duration regularly --- validate/tools/gst-validate-transcoding.c | 27 +++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/validate/tools/gst-validate-transcoding.c b/validate/tools/gst-validate-transcoding.c index 88e111987b..29b9f9b835 100644 --- a/validate/tools/gst-validate-transcoding.c +++ b/validate/tools/gst-validate-transcoding.c @@ -63,6 +63,32 @@ intr_handler (gpointer user_data) } #endif /* G_OS_UNIX */ +static gboolean +print_position (void) +{ + GstQuery *query; + gint64 position, duration; + + gdouble rate = 1.0; + GstFormat format = GST_FORMAT_TIME; + + gst_element_query_position (pipeline, format, &position); + + format = GST_FORMAT_TIME; + gst_element_query_duration (pipeline, format, &duration); + + query = gst_query_new_segment (GST_FORMAT_DEFAULT); + if (gst_element_query (pipeline, query)) + gst_query_parse_segment (query, &rate, NULL, NULL, NULL); + gst_query_unref (query); + + g_print ("\r", GST_TIME_ARGS (position), GST_TIME_ARGS (duration), + rate); + + return TRUE; +} + static gboolean bus_callback (GstBus * bus, GstMessage * message, gpointer data) { @@ -412,6 +438,7 @@ main (int argc, gchar ** argv) if (gst_element_set_state (pipeline, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE) goto exit; + g_timeout_add (50, (GSourceFunc) print_position, NULL); g_main_loop_run (mainloop); for (tmp = gst_validate_runner_get_reports (runner); tmp; tmp = tmp->next) {