Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
gst-play: add --start-position command line argument
  • Loading branch information
Stéphane Cerveau authored and GStreamer Marge Bot committed Apr 30, 2021
1 parent b143470 commit a7114f4
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions tools/gst-play.c
Expand Up @@ -102,6 +102,7 @@ typedef struct

GstPlayTrickMode trick_mode;
gdouble rate;
gdouble start_position;
} GstPlay;

static gboolean quiet = FALSE;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit a7114f4

Please sign in to comment.