From 7ccaac9bf221d9c007e627d4af4dd5d26b554db5 Mon Sep 17 00:00:00 2001 From: Mark Nauwelaerts Date: Wed, 30 Nov 2011 16:15:35 +0100 Subject: [PATCH] ges-launch: allow for optional audio or video track --- tools/ges-launch.c | 58 ++++++++++++++++++++++++++++------------------ 1 file changed, 36 insertions(+), 22 deletions(-) diff --git a/tools/ges-launch.c b/tools/ges-launch.c index 4be413807c..6f9232599d 100644 --- a/tools/ges-launch.c +++ b/tools/ges-launch.c @@ -128,44 +128,50 @@ make_encoding_profile (gchar * audio, gchar * video, gchar * video_restriction, NULL); gst_caps_unref (caps); - caps = gst_caps_from_string (audio); - stream = (GstEncodingProfile *) - gst_encoding_audio_profile_new (caps, audio_preset, NULL, 0); - gst_encoding_container_profile_add_profile (profile, stream); - gst_caps_unref (caps); + if (audio) { + caps = gst_caps_from_string (audio); + stream = (GstEncodingProfile *) + gst_encoding_audio_profile_new (caps, audio_preset, NULL, 0); + gst_encoding_container_profile_add_profile (profile, stream); + gst_caps_unref (caps); + } - caps = gst_caps_from_string (video); - stream = (GstEncodingProfile *) - gst_encoding_video_profile_new (caps, video_preset, NULL, 0); - if (video_restriction) - gst_encoding_profile_set_restriction (stream, - gst_caps_from_string (video_restriction)); - gst_encoding_container_profile_add_profile (profile, stream); - gst_caps_unref (caps); + if (video) { + caps = gst_caps_from_string (video); + stream = (GstEncodingProfile *) + gst_encoding_video_profile_new (caps, video_preset, NULL, 0); + if (video_restriction) + gst_encoding_profile_set_restriction (stream, + gst_caps_from_string (video_restriction)); + gst_encoding_container_profile_add_profile (profile, stream); + gst_caps_unref (caps); + } return (GstEncodingProfile *) profile; } static GESTimeline * -create_timeline (int nbargs, gchar ** argv) +create_timeline (int nbargs, gchar ** argv, gchar * audio, gchar * video) { GESTimelineLayer *layer; - GESTrack *tracka, *trackv; + GESTrack *tracka = NULL, *trackv = NULL; GESTimeline *timeline; guint i; timeline = ges_timeline_new (); - tracka = ges_track_audio_raw_new (); - trackv = ges_track_video_raw_new (); + if (audio) + tracka = ges_track_audio_raw_new (); + if (video) + trackv = ges_track_video_raw_new (); /* We are only going to be doing one layer of timeline objects */ layer = (GESTimelineLayer *) ges_simple_timeline_layer_new (); /* Add the tracks and the layer to the timeline */ if (!ges_timeline_add_layer (timeline, layer) || - !ges_timeline_add_track (timeline, tracka) || - !ges_timeline_add_track (timeline, trackv)) + !(!audio || ges_timeline_add_track (timeline, tracka)) || + !(!video || ges_timeline_add_track (timeline, trackv))) goto build_failure; /* Here we've finished initializing our timeline, we're @@ -263,7 +269,8 @@ build_failure: } static GESTimelinePipeline * -create_pipeline (gchar * load_path, gchar * save_path, int argc, char **argv) +create_pipeline (gchar * load_path, gchar * save_path, int argc, char **argv, + gchar * audio, gchar * video) { GESTimelinePipeline *pipeline = NULL; GESTimeline *timeline = NULL; @@ -287,7 +294,7 @@ create_pipeline (gchar * load_path, gchar * save_path, int argc, char **argv) g_free (uri); } else /* Normal timeline creation */ - if (!(timeline = create_timeline (argc, argv))) + if (!(timeline = create_timeline (argc, argv, audio, video))) goto failure; /* save project if path is given. we do this now in case GES crashes or @@ -502,8 +509,15 @@ main (int argc, gchar ** argv) g_option_context_free (ctx); + /* normalize */ + if (strcmp (audio, "none") == 0) + audio = NULL; + if (strcmp (video, "none") == 0) + video = NULL; + /* Create the pipeline */ - pipeline = create_pipeline (load_path, save_path, argc - 1, argv + 1); + pipeline = create_pipeline (load_path, save_path, argc - 1, argv + 1, + audio, video); if (!pipeline) exit (1);