1 /* GStreamer Editing Services
2 * Copyright (C) 2010 Brandon Lewis <brandon@alum.berkeley.edu>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
29 GESClip *make_source (char *path, guint64 start, guint64 duration,
30 gint priority, gchar * text);
32 GESPipeline *make_timeline (char *path, float duration, char *text);
35 make_source (char *path, guint64 start, guint64 duration, gint priority,
38 gchar *uri = gst_filename_to_uri (path, NULL);
40 GESClip *ret = GES_CLIP (ges_uri_clip_new (uri));
43 "start", (guint64) start,
44 "duration", (guint64) duration,
45 "priority", (guint32) priority, "in-point", (guint64) 0,
54 make_timeline (char *path, float duration, char *text)
56 GESTimeline *timeline;
57 GESTrack *trackv, *tracka;
60 GESPipeline *pipeline;
63 pipeline = ges_pipeline_new ();
65 ges_pipeline_set_mode (pipeline, GES_PIPELINE_MODE_PREVIEW_VIDEO);
67 timeline = ges_timeline_new ();
68 ges_pipeline_set_timeline (pipeline, timeline);
70 trackv = GES_TRACK (ges_video_track_new ());
71 ges_timeline_add_track (timeline, trackv);
73 tracka = GES_TRACK (ges_audio_track_new ());
74 ges_timeline_add_track (timeline, tracka);
76 layer1 = GES_LAYER (ges_layer_new ());
77 g_object_set (layer1, "priority", (gint32) 0, NULL);
79 if (!ges_timeline_add_layer (timeline, layer1))
82 aduration = (guint64) (duration * GST_SECOND);
83 srca = make_source (path, 0, aduration, 1, text);
84 ges_layer_add_clip (layer1, srca);
90 main (int argc, char **argv)
94 GESPipeline *pipeline;
99 GOptionEntry options[] = {
100 {"duration", 'd', 0, G_OPTION_ARG_DOUBLE, &duration,
101 "duration of transition", "seconds"},
102 {"path", 'p', 0, G_OPTION_ARG_STRING, &path,
103 "path to file", "path"},
104 {"text", 't', 0, G_OPTION_ARG_STRING, &text,
105 "text to render", "text"},
109 ctx = g_option_context_new ("- transition between two media files");
110 g_option_context_add_main_entries (ctx, options, NULL);
111 g_option_context_add_group (ctx, gst_init_get_option_group ());
113 if (!g_option_context_parse (ctx, &argc, &argv, &err)) {
114 gst_print ("Error initializing %s\n", err->message);
115 g_option_context_free (ctx);
116 g_clear_error (&err);
121 gst_print ("%s", g_option_context_get_help (ctx, TRUE, NULL));
125 g_option_context_free (ctx);
129 pipeline = make_timeline (path, duration, text);
131 mainloop = g_main_loop_new (NULL, FALSE);
132 g_timeout_add_seconds ((duration) + 1, (GSourceFunc) g_main_loop_quit,
134 gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING);
135 g_main_loop_run (mainloop);