mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-06-05 06:58:56 +00:00
gst-launch: add -q/--quiet option to supress any non error output.
Having no output is nice for scripting. Also update the manpage.
This commit is contained in:
parent
1c716ae407
commit
a12b0a60d8
2 changed files with 35 additions and 15 deletions
|
@ -28,7 +28,10 @@ easy way to construct pipelines from pipeline descriptions.
|
||||||
Print help synopsis and available FLAGS
|
Print help synopsis and available FLAGS
|
||||||
.TP 8
|
.TP 8
|
||||||
.B \-v, \-\-verbose
|
.B \-v, \-\-verbose
|
||||||
Output status information
|
Output status information and property notifications
|
||||||
|
.TP 8
|
||||||
|
.B \-v, \-\-quiet
|
||||||
|
Do not print any progress information
|
||||||
.TP 8
|
.TP 8
|
||||||
.B \-m, \-\-messages
|
.B \-m, \-\-messages
|
||||||
Output messages posted on the pipeline's bus
|
Output messages posted on the pipeline's bus
|
||||||
|
|
|
@ -58,6 +58,7 @@ static gboolean caught_intr = FALSE;
|
||||||
|
|
||||||
static GstElement *pipeline;
|
static GstElement *pipeline;
|
||||||
static gboolean caught_error = FALSE;
|
static gboolean caught_error = FALSE;
|
||||||
|
static gboolean quiet = FALSE;
|
||||||
static gboolean tags = FALSE;
|
static gboolean tags = FALSE;
|
||||||
static gboolean messages = FALSE;
|
static gboolean messages = FALSE;
|
||||||
static gboolean is_live = FALSE;
|
static gboolean is_live = FALSE;
|
||||||
|
@ -522,6 +523,7 @@ event_loop (GstElement * pipeline, gboolean blocking, GstState target_state)
|
||||||
gint percent;
|
gint percent;
|
||||||
|
|
||||||
gst_message_parse_buffering (message, &percent);
|
gst_message_parse_buffering (message, &percent);
|
||||||
|
if(!quiet)
|
||||||
fprintf (stderr, "%s %d%% \r", _("buffering..."), percent);
|
fprintf (stderr, "%s %d%% \r", _("buffering..."), percent);
|
||||||
|
|
||||||
/* no state management needed for live pipelines */
|
/* no state management needed for live pipelines */
|
||||||
|
@ -533,6 +535,7 @@ event_loop (GstElement * pipeline, gboolean blocking, GstState target_state)
|
||||||
buffering = FALSE;
|
buffering = FALSE;
|
||||||
/* if the desired state is playing, go back */
|
/* if the desired state is playing, go back */
|
||||||
if (target_state == GST_STATE_PLAYING) {
|
if (target_state == GST_STATE_PLAYING) {
|
||||||
|
if(!quiet)
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("Done buffering, setting pipeline to PLAYING ...\n"));
|
_("Done buffering, setting pipeline to PLAYING ...\n"));
|
||||||
gst_element_set_state (pipeline, GST_STATE_PLAYING);
|
gst_element_set_state (pipeline, GST_STATE_PLAYING);
|
||||||
|
@ -542,6 +545,7 @@ event_loop (GstElement * pipeline, gboolean blocking, GstState target_state)
|
||||||
/* buffering busy */
|
/* buffering busy */
|
||||||
if (buffering == FALSE && target_state == GST_STATE_PLAYING) {
|
if (buffering == FALSE && target_state == GST_STATE_PLAYING) {
|
||||||
/* we were not buffering but PLAYING, PAUSE the pipeline. */
|
/* we were not buffering but PLAYING, PAUSE the pipeline. */
|
||||||
|
if(!quiet)
|
||||||
fprintf (stderr, _("Buffering, setting pipeline to PAUSED ...\n"));
|
fprintf (stderr, _("Buffering, setting pipeline to PAUSED ...\n"));
|
||||||
gst_element_set_state (pipeline, GST_STATE_PAUSED);
|
gst_element_set_state (pipeline, GST_STATE_PAUSED);
|
||||||
}
|
}
|
||||||
|
@ -563,6 +567,7 @@ event_loop (GstElement * pipeline, gboolean blocking, GstState target_state)
|
||||||
if (gst_structure_has_name (s, "GstLaunchInterrupt")) {
|
if (gst_structure_has_name (s, "GstLaunchInterrupt")) {
|
||||||
/* this application message is posted when we caught an interrupt and
|
/* this application message is posted when we caught an interrupt and
|
||||||
* we need to stop the pipeline. */
|
* we need to stop the pipeline. */
|
||||||
|
if(!quiet)
|
||||||
fprintf (stderr, _("Interrupt: Stopping pipeline ...\n"));
|
fprintf (stderr, _("Interrupt: Stopping pipeline ...\n"));
|
||||||
/* return TRUE when we caught an interrupt */
|
/* return TRUE when we caught an interrupt */
|
||||||
res = TRUE;
|
res = TRUE;
|
||||||
|
@ -601,6 +606,8 @@ main (int argc, char *argv[])
|
||||||
N_("Output tags (also known as metadata)"), NULL},
|
N_("Output tags (also known as metadata)"), NULL},
|
||||||
{"verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose,
|
{"verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose,
|
||||||
N_("Output status information and property notifications"), NULL},
|
N_("Output status information and property notifications"), NULL},
|
||||||
|
{"quiet", 'q', 0, G_OPTION_ARG_NONE, &quiet,
|
||||||
|
N_("Do not print any progress information"), NULL},
|
||||||
{"messages", 'm', 0, G_OPTION_ARG_NONE, &messages,
|
{"messages", 'm', 0, G_OPTION_ARG_NONE, &messages,
|
||||||
N_("Output messages"), NULL},
|
N_("Output messages"), NULL},
|
||||||
{"exclude", 'X', 0, G_OPTION_ARG_NONE, &exclude_args,
|
{"exclude", 'X', 0, G_OPTION_ARG_NONE, &exclude_args,
|
||||||
|
@ -721,6 +728,7 @@ main (int argc, char *argv[])
|
||||||
gst_bin_add (GST_BIN (real_pipeline), pipeline);
|
gst_bin_add (GST_BIN (real_pipeline), pipeline);
|
||||||
pipeline = real_pipeline;
|
pipeline = real_pipeline;
|
||||||
}
|
}
|
||||||
|
if(!quiet)
|
||||||
fprintf (stderr, _("Setting pipeline to PAUSED ...\n"));
|
fprintf (stderr, _("Setting pipeline to PAUSED ...\n"));
|
||||||
ret = gst_element_set_state (pipeline, GST_STATE_PAUSED);
|
ret = gst_element_set_state (pipeline, GST_STATE_PAUSED);
|
||||||
|
|
||||||
|
@ -731,10 +739,12 @@ main (int argc, char *argv[])
|
||||||
event_loop (pipeline, FALSE, GST_STATE_VOID_PENDING);
|
event_loop (pipeline, FALSE, GST_STATE_VOID_PENDING);
|
||||||
goto end;
|
goto end;
|
||||||
case GST_STATE_CHANGE_NO_PREROLL:
|
case GST_STATE_CHANGE_NO_PREROLL:
|
||||||
|
if(!quiet)
|
||||||
fprintf (stderr, _("Pipeline is live and does not need PREROLL ...\n"));
|
fprintf (stderr, _("Pipeline is live and does not need PREROLL ...\n"));
|
||||||
is_live = TRUE;
|
is_live = TRUE;
|
||||||
break;
|
break;
|
||||||
case GST_STATE_CHANGE_ASYNC:
|
case GST_STATE_CHANGE_ASYNC:
|
||||||
|
if(!quiet)
|
||||||
fprintf (stderr, _("Pipeline is PREROLLING ...\n"));
|
fprintf (stderr, _("Pipeline is PREROLLING ...\n"));
|
||||||
caught_error = event_loop (pipeline, TRUE, GST_STATE_PAUSED);
|
caught_error = event_loop (pipeline, TRUE, GST_STATE_PAUSED);
|
||||||
if (caught_error) {
|
if (caught_error) {
|
||||||
|
@ -744,6 +754,7 @@ main (int argc, char *argv[])
|
||||||
state = GST_STATE_PAUSED;
|
state = GST_STATE_PAUSED;
|
||||||
/* fallthrough */
|
/* fallthrough */
|
||||||
case GST_STATE_CHANGE_SUCCESS:
|
case GST_STATE_CHANGE_SUCCESS:
|
||||||
|
if(!quiet)
|
||||||
fprintf (stderr, _("Pipeline is PREROLLED ...\n"));
|
fprintf (stderr, _("Pipeline is PREROLLED ...\n"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -756,7 +767,9 @@ main (int argc, char *argv[])
|
||||||
GstClockTime tfthen, tfnow;
|
GstClockTime tfthen, tfnow;
|
||||||
GstClockTimeDiff diff;
|
GstClockTimeDiff diff;
|
||||||
|
|
||||||
|
if(!quiet)
|
||||||
fprintf (stderr, _("Setting pipeline to PLAYING ...\n"));
|
fprintf (stderr, _("Setting pipeline to PLAYING ...\n"));
|
||||||
|
|
||||||
if (gst_element_set_state (pipeline,
|
if (gst_element_set_state (pipeline,
|
||||||
GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE) {
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE) {
|
||||||
GstMessage *err_msg;
|
GstMessage *err_msg;
|
||||||
|
@ -791,21 +804,25 @@ main (int argc, char *argv[])
|
||||||
/* iterate mainloop to process pending stuff */
|
/* iterate mainloop to process pending stuff */
|
||||||
while (g_main_context_iteration (NULL, FALSE));
|
while (g_main_context_iteration (NULL, FALSE));
|
||||||
|
|
||||||
|
if(!quiet)
|
||||||
fprintf (stderr, _("Setting pipeline to PAUSED ...\n"));
|
fprintf (stderr, _("Setting pipeline to PAUSED ...\n"));
|
||||||
gst_element_set_state (pipeline, GST_STATE_PAUSED);
|
gst_element_set_state (pipeline, GST_STATE_PAUSED);
|
||||||
if (!caught_error)
|
if (!caught_error)
|
||||||
gst_element_get_state (pipeline, &state, &pending, GST_CLOCK_TIME_NONE);
|
gst_element_get_state (pipeline, &state, &pending, GST_CLOCK_TIME_NONE);
|
||||||
|
if(!quiet)
|
||||||
fprintf (stderr, _("Setting pipeline to READY ...\n"));
|
fprintf (stderr, _("Setting pipeline to READY ...\n"));
|
||||||
gst_element_set_state (pipeline, GST_STATE_READY);
|
gst_element_set_state (pipeline, GST_STATE_READY);
|
||||||
gst_element_get_state (pipeline, &state, &pending, GST_CLOCK_TIME_NONE);
|
gst_element_get_state (pipeline, &state, &pending, GST_CLOCK_TIME_NONE);
|
||||||
|
|
||||||
end:
|
end:
|
||||||
|
if(!quiet)
|
||||||
fprintf (stderr, _("Setting pipeline to NULL ...\n"));
|
fprintf (stderr, _("Setting pipeline to NULL ...\n"));
|
||||||
gst_element_set_state (pipeline, GST_STATE_NULL);
|
gst_element_set_state (pipeline, GST_STATE_NULL);
|
||||||
gst_element_get_state (pipeline, &state, &pending, GST_CLOCK_TIME_NONE);
|
gst_element_get_state (pipeline, &state, &pending, GST_CLOCK_TIME_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf (stderr, _("FREEING pipeline ...\n"));
|
if(!quiet)
|
||||||
|
fprintf (stderr, _("Freeing pipeline ...\n"));
|
||||||
gst_object_unref (pipeline);
|
gst_object_unref (pipeline);
|
||||||
|
|
||||||
gst_deinit ();
|
gst_deinit ();
|
||||||
|
|
Loading…
Reference in a new issue