GESTimelinePipeline * make_timeline (char *path, float duration, char *text, guint32 color, gdouble xpos, gdouble ypos) { GESTimeline *timeline; GESTrack *trackv, *tracka; GESTimelineLayer *layer1; GESTimelineObject *srca; GESTimelineObject *overlay; GESTimelinePipeline *pipeline; guint64 aduration; pipeline = ges_timeline_pipeline_new (); ges_timeline_pipeline_set_mode (pipeline, TIMELINE_MODE_PREVIEW_VIDEO); timeline = ges_timeline_new (); ges_timeline_pipeline_add_timeline (pipeline, timeline); trackv = ges_track_video_raw_new (); ges_timeline_add_track (timeline, trackv); tracka = ges_track_audio_raw_new (); ges_timeline_add_track (timeline, tracka); layer1 = GES_TIMELINE_LAYER (ges_timeline_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_timeline_layer_add_object (layer1, srca); ges_timeline_layer_add_object (layer1, overlay); return pipeline; }
/* A simple timeline with 3 audio/video sources */ int main (int argc, gchar ** argv) { GESAsset *src_asset; GESTimelinePipeline *pipeline; GESTimeline *timeline; GESClip *source; GESTimelineLayer *layer; GMainLoop *mainloop; /* Initialize GStreamer (this will parse environment variables and commandline * arguments. */ gst_init (&argc, &argv); /* Initialize the GStreamer Editing Services */ ges_init (); /* Setup of a A/V timeline */ /* This is our main GESTimeline */ timeline = ges_timeline_new_audio_video (); /* We are only going to be doing one layer of clips */ layer = ges_timeline_layer_new (); /* Add the tracks and the layer to the timeline */ if (!ges_timeline_add_layer (timeline, layer)) return -1; /* We create a simple asset able to extract GESTestClip */ src_asset = ges_asset_request (GES_TYPE_TEST_CLIP, NULL, NULL); /* Add sources to our layer */ ges_timeline_layer_add_asset (layer, src_asset, 0, 0, GST_SECOND, 1, GES_TRACK_TYPE_UNKNOWN); source = ges_timeline_layer_add_asset (layer, src_asset, GST_SECOND, 0, GST_SECOND, 1, GES_TRACK_TYPE_UNKNOWN); g_object_set (source, "freq", 480.0, "vpattern", 2, NULL); ges_timeline_layer_add_asset (layer, src_asset, 2 * GST_SECOND, 0, GST_SECOND, 1, GES_TRACK_TYPE_UNKNOWN); /* In order to view our timeline, let's grab a convenience pipeline to put * our timeline in. */ pipeline = ges_timeline_pipeline_new (); /* Add the timeline to that pipeline */ if (!ges_timeline_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 (4, (GSourceFunc) g_main_loop_quit, mainloop); g_main_loop_run (mainloop); return 0; }