From a7114f4b88d84d007905c838df4dba7cde14eb4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Cerveau?= Date: Tue, 27 Apr 2021 10:30:15 +0200 Subject: [PATCH] gst-play: add --start-position command line argument Part-of: --- tools/gst-play.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/tools/gst-play.c b/tools/gst-play.c index 12226532bc..7a454cdc5e 100644 --- a/tools/gst-play.c +++ b/tools/gst-play.c @@ -102,6 +102,7 @@ typedef struct GstPlayTrickMode trick_mode; gdouble rate; + gdouble start_position; } GstPlay; static gboolean quiet = FALSE; @@ -151,7 +152,7 @@ gst_play_printf (const gchar * format, ...) static GstPlay * play_new (gchar ** uris, const gchar * audio_sink, const gchar * video_sink, gboolean gapless, gdouble initial_volume, gboolean verbose, - const gchar * flags_string, gboolean use_playbin3) + const gchar * flags_string, gboolean use_playbin3, gdouble start_position) { GstElement *sink, *playbin; GstPlay *play; @@ -251,7 +252,7 @@ play_new (gchar ** uris, const gchar * audio_sink, const gchar * video_sink, play->rate = 1.0; play->trick_mode = GST_PLAY_TRICK_MODE_NONE; - + play->start_position = start_position; return play; } @@ -357,6 +358,11 @@ play_bus_msg (GstBus * bus, GstMessage * msg, gpointer user_data) --play->cur_idx; play_next (play); } + if (play->start_position > 0.0) { + play_do_seek (play, play->start_position * GST_SECOND, + play->rate, play->trick_mode); + play->start_position = 0; + } break; case GST_MESSAGE_BUFFERING:{ gint percent; @@ -1469,6 +1475,7 @@ main (int argc, char **argv) gboolean gapless = FALSE; gboolean shuffle = FALSE; gdouble volume = -1; + gdouble start_position = 0; gchar **filenames = NULL; gchar *audio_sink = NULL; gchar *video_sink = NULL; @@ -1500,6 +1507,8 @@ main (int argc, char **argv) N_("Disable interactive control via the keyboard"), NULL}, {"volume", 0, 0, G_OPTION_ARG_DOUBLE, &volume, N_("Volume"), NULL}, + {"start-position", 's', 0, G_OPTION_ARG_DOUBLE, &start_position, + N_("Start position in seconds."), NULL}, {"playlist", 0, 0, G_OPTION_ARG_FILENAME, &playlist_file, N_("Playlist file containing input media files"), NULL}, {"instant-rate-changes", 'i', 0, G_OPTION_ARG_NONE, &instant_rate_changes, @@ -1626,7 +1635,7 @@ main (int argc, char **argv) /* prepare */ play = play_new (uris, audio_sink, video_sink, gapless, volume, verbose, - flags, use_playbin3); + flags, use_playbin3, start_position); if (play == NULL) { gst_printerr