gboolean play_timeline (GESTimeline * timeline) { GstBus *bus; GESPipeline *pipeline; GMainLoop *loop = g_main_loop_new (NULL, FALSE); ges_timeline_commit (timeline); pipeline = ges_pipeline_new (); bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline)); gst_bus_add_watch (bus, (GstBusFunc) my_bus_callback, loop); gst_object_unref (bus); ges_pipeline_set_timeline (pipeline, timeline); gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING); gst_element_get_state (GST_ELEMENT (pipeline), NULL, NULL, -1); g_main_loop_run (loop); gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL); gst_element_get_state (GST_ELEMENT (pipeline), NULL, NULL, -1); gst_object_unref (pipeline); return TRUE; }
int main (int argc, char **argv) { GESTimeline *timeline; GESLayer *layer; GError **error = NULL; GESAsset *asset; const gchar *url = "file:///home/bmonkey/workspace/ges/ges-renderer/data/sd/sintel_trailer-480p.mp4"; const gchar *exportURL = "file:///home/bmonkey/workspace/ges/ges-renderer/transition.mp4"; gst_init (&argc, &argv); ges_init (); timeline = ges_timeline_new_audio_video (); layer = ges_layer_new (); g_object_set (layer, "auto-transition", TRUE, NULL); ges_timeline_add_layer (timeline, layer); asset = GES_ASSET (ges_uri_clip_asset_request_sync (url, error)); ges_layer_add_asset (layer, asset, 0 * GST_SECOND, 0 * GST_SECOND, 10 * GST_SECOND, GES_TRACK_TYPE_VIDEO); ges_layer_add_asset (layer, asset, 5 * GST_SECOND, 20 * GST_SECOND, 10 * GST_SECOND, GES_TRACK_TYPE_VIDEO); ges_timeline_commit (timeline); duration = ges_timeline_get_duration (timeline); pipeline = ges_pipeline_new (); ges_pipeline_set_timeline (pipeline, timeline); GESRendererProfile pal = { 720, 576, 25, PROFILE_AAC_H264_QUICKTIME }; GstCaps *settings = gst_caps_from_renderer_profile (&pal); GstEncodingProfile *profile = profile_get_encoding_profile (settings); ges_pipeline_set_render_settings (pipeline, exportURL, profile); ges_pipeline_set_mode (pipeline, GES_PIPELINE_MODE_RENDER); GMainLoop *mainloop; mainloop = g_main_loop_new (NULL, FALSE); GstBus *bus; bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline)); g_signal_connect (bus, "message", (GCallback) bus_message_cb, mainloop); g_timeout_add (100, (GSourceFunc) ges_renderer_print_progress, NULL); gst_bus_add_signal_watch (bus); gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING); g_main_loop_run (mainloop); g_main_loop_unref (mainloop); return 0; }
int main (int argc, char **argv) { GMainLoop *mainloop = NULL; GESTimeline *timeline; GESLayer *layer = NULL; GstBus *bus = NULL; guint i; if (argc < 3) { g_print ("Usage: %s <output uri> <list of files>\n", argv[0]); return -1; } gst_init (&argc, &argv); ges_init (); timeline = ges_timeline_new_audio_video (); layer = (GESLayer *) ges_simple_layer_new (); if (!ges_timeline_add_layer (timeline, layer)) return -1; output_uri = argv[1]; assetsCount = argc - 2; for (i = 2; i < argc; i++) { ges_asset_request_async (GES_TYPE_URI_CLIP, argv[i], NULL, (GAsyncReadyCallback) asset_loaded_cb, mainloop); } /* In order to view our timeline, let's grab a convenience pipeline to put * our timeline in. */ pipeline = ges_pipeline_new (); /* Add the timeline to that pipeline */ if (!ges_pipeline_add_timeline (pipeline, timeline)) return -1; mainloop = g_main_loop_new (NULL, FALSE); bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline)); gst_bus_add_signal_watch (bus); g_signal_connect (bus, "message", G_CALLBACK (bus_message_cb), mainloop); g_main_loop_run (mainloop); return 0; }
GESPipeline * ges_test_create_pipeline (GESTimeline * timeline) { GESPipeline *pipeline; pipeline = ges_pipeline_new (); fail_unless (ges_pipeline_set_timeline (pipeline, timeline)); g_object_set (pipeline, "audio-sink", gst_element_factory_make ("fakesink", "test-audiofakesink"), "video-sink", gst_element_factory_make ("fakesink", "test-videofakesink"), NULL); return pipeline; }
GESPipeline * make_timeline (char *path, float duration, char *text, guint32 color, gdouble xpos, gdouble ypos) { GESTimeline *timeline; GESTrack *trackv, *tracka; GESLayer *layer1; GESClip *srca; GESClip *overlay; GESPipeline *pipeline; guint64 aduration; pipeline = ges_pipeline_new (); ges_pipeline_set_mode (pipeline, TIMELINE_MODE_PREVIEW_VIDEO); timeline = ges_timeline_new (); ges_pipeline_add_timeline (pipeline, timeline); trackv = GES_TRACK (ges_video_track_new ()); ges_timeline_add_track (timeline, trackv); tracka = GES_TRACK (ges_audio_track_new ()); ges_timeline_add_track (timeline, tracka); layer1 = GES_LAYER (ges_layer_new ()); g_object_set (layer1, "priority", (gint32) 0, NULL); if (!ges_timeline_add_layer (timeline, layer1)) exit (-1); aduration = (guint64) (duration * GST_SECOND); srca = make_source (path, 0, aduration, 1); overlay = make_overlay (text, 0, aduration, 0, color, xpos, ypos); ges_layer_add_clip (layer1, srca); ges_layer_add_clip (layer1, overlay); return pipeline; }
static GESPipeline * create_timeline (void) { GESPipeline *pipeline; GESLayer *layer; GESTrack *tracka, *trackv; GESTimeline *timeline; GESClip *src; timeline = ges_timeline_new (); tracka = GES_TRACK (ges_audio_track_new ()); trackv = GES_TRACK (ges_video_track_new ()); layer = (GESLayer *) ges_simple_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)) return NULL; /* Add the main audio/video file */ src = GES_CLIP (ges_test_clip_new ()); g_object_set (src, "vpattern", GES_VIDEO_TEST_PATTERN_SNOW, "duration", 10 * GST_SECOND, NULL); ges_simple_layer_add_object ((GESSimpleLayer *) layer, GES_CLIP (src), 0); pipeline = ges_pipeline_new (); if (!ges_pipeline_add_timeline (pipeline, timeline)) return NULL; return pipeline; }
int main (int argc, gchar ** argv) { GError *err = NULL; GOptionContext *ctx; GESPipeline *pipeline; GESTimeline *timeline; GESTrack *tracka, *trackv; GESLayer *layer1, *layer2; GESUriClip *src; GMainLoop *mainloop; gint inpoint = 0, duration = 10; gboolean mute = FALSE; gchar *audiofile = NULL; GOptionEntry options[] = { {"inpoint", 'i', 0, G_OPTION_ARG_INT, &inpoint, "in-point in the file (in seconds, default:0s)", "seconds"}, {"duration", 'd', 0, G_OPTION_ARG_INT, &duration, "duration to use from the file (in seconds, default:10s)", "seconds"}, {"mute", 'm', 0, G_OPTION_ARG_NONE, &mute, "Whether to mute the audio from the file",}, {"audiofile", 'a', 0, G_OPTION_ARG_FILENAME, &audiofile, "Use this audiofile instead of the original audio from the file", "audiofile"}, {NULL} }; ctx = g_option_context_new ("- Plays an video file with sound (origin/muted/replaced)"); g_option_context_add_main_entries (ctx, options, NULL); g_option_context_add_group (ctx, gst_init_get_option_group ()); if (!g_option_context_parse (ctx, &argc, &argv, &err)) { g_print ("Error initializing %s\n", err->message); exit (1); } if (argc == 1) { g_print ("%s", g_option_context_get_help (ctx, TRUE, NULL)); exit (0); } g_option_context_free (ctx); ges_init (); /* Create an Audio/Video pipeline with two layers */ pipeline = ges_pipeline_new (); timeline = ges_timeline_new (); tracka = GES_TRACK (ges_audio_track_new ()); trackv = GES_TRACK (ges_video_track_new ()); layer1 = ges_layer_new (); layer2 = ges_layer_new (); g_object_set (layer2, "priority", 1, NULL); if (!ges_timeline_add_layer (timeline, layer1) || !ges_timeline_add_layer (timeline, layer2) || !ges_timeline_add_track (timeline, tracka) || !ges_timeline_add_track (timeline, trackv) || !ges_pipeline_set_timeline (pipeline, timeline)) return -1; if (1) { gchar *uri = gst_filename_to_uri (argv[1], NULL); /* Add the main audio/video file */ src = ges_uri_clip_new (uri); g_free (uri); g_object_set (src, "start", 0, "in-point", inpoint * GST_SECOND, "duration", duration * GST_SECOND, "mute", mute, NULL); ges_layer_add_clip (layer1, GES_CLIP (src)); } /* Play the pipeline */ gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING); mainloop = g_main_loop_new (NULL, FALSE); g_timeout_add_seconds (duration + 1, (GSourceFunc) g_main_loop_quit, mainloop); g_main_loop_run (mainloop); return 0; }
/* A image sequence test */ int main (int argc, gchar ** argv) { GError *err = NULL; GOptionContext *ctx; GESPipeline *pipeline; GESTimeline *timeline; GESAsset *asset; GESLayer *layer; GMainLoop *mainloop; GESTrack *track; gint duration = 10; gchar *filepattern = NULL; GOptionEntry options[] = { {"duration", 'd', 0, G_OPTION_ARG_INT, &duration, "duration to use from the file (in seconds, default:10s)", "seconds"}, {"pattern-url", 'u', 0, G_OPTION_ARG_FILENAME, &filepattern, "Pattern of the files. i.e. multifile:///foo/%04d.jpg", "pattern-url"}, {NULL} }; ctx = g_option_context_new ("- Plays an image sequence"); g_option_context_add_main_entries (ctx, options, NULL); g_option_context_add_group (ctx, gst_init_get_option_group ()); if (!g_option_context_parse (ctx, &argc, &argv, &err)) { g_print ("Error initializing %s\n", err->message); exit (1); } if (filepattern == NULL) { g_print ("%s", g_option_context_get_help (ctx, TRUE, NULL)); exit (0); } g_option_context_free (ctx); gst_init (&argc, &argv); ges_init (); timeline = ges_timeline_new (); track = GES_TRACK (ges_video_track_new ()); ges_timeline_add_track (timeline, track); layer = ges_layer_new (); if (!ges_timeline_add_layer (timeline, layer)) return -1; asset = GES_ASSET (ges_uri_clip_asset_request_sync (filepattern, &err)); ges_layer_add_asset (layer, asset, 0, 0, 5 * GST_SECOND, GES_TRACK_TYPE_VIDEO); pipeline = ges_pipeline_new (); if (!ges_pipeline_set_timeline (pipeline, timeline)) return -1; gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING); mainloop = g_main_loop_new (NULL, FALSE); g_timeout_add_seconds (4, (GSourceFunc) g_main_loop_quit, mainloop); g_main_loop_run (mainloop); return 0; }
int main (int argc, gchar ** argv) { GESPipeline *pipeline; GESTimeline *timeline; GESTrack *tracka; GESLayer *layer; GMainLoop *mainloop; GstClockTime offset = 0; guint i; if (argc < 2) { g_print ("Usage: %s <list of audio files>\n", argv[0]); return -1; } /* Initialize GStreamer (this will parse environment variables and commandline * arguments. */ gst_init (&argc, &argv); /* Initialize the GStreamer Editing Services */ ges_init (); /* Setup of an audio timeline */ /* This is our main GESTimeline */ timeline = ges_timeline_new (); tracka = GES_TRACK (ges_audio_track_new ()); /* We are only going to be doing one layer of clips */ layer = ges_layer_new (); /* Add the tracks and the layer to the timeline */ if (!ges_timeline_add_layer (timeline, layer)) return -1; if (!ges_timeline_add_track (timeline, tracka)) return -1; /* Here we've finished initializing our timeline, we're * ready to start using it... by solely working with the layer ! */ for (i = 1; i < argc; i++, offset += GST_SECOND) { gchar *uri = gst_filename_to_uri (argv[i], NULL); GESUriClip *src = ges_uri_clip_new (uri); g_assert (src); g_free (uri); g_object_set (src, "start", offset, "duration", GST_SECOND, NULL); ges_layer_add_clip (layer, (GESClip *) src); } /* In order to listen our timeline, let's grab a convenience pipeline to put * our timeline in. */ pipeline = ges_pipeline_new (); /* Add the timeline to that pipeline */ if (!ges_pipeline_add_timeline (pipeline, timeline)) return -1; /* The following is standard usage of a GStreamer pipeline (note how you * haven't had to care about GStreamer so far ?). * * We set the pipeline to playing ... */ gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING); /* ... and we start a GMainLoop. GES **REQUIRES** a GMainLoop to be running in * order to function properly ! */ mainloop = g_main_loop_new (NULL, FALSE); /* Simple code to have the mainloop shutdown after 4s */ g_timeout_add_seconds (argc - 1, (GSourceFunc) g_main_loop_quit, mainloop); g_main_loop_run (mainloop); return 0; }