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., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
29 GESTimelineObject *make_source (char *path, guint64 start, guint64 duration,
30 gint priority, gchar * text);
32 GESTimelinePipeline *make_timeline (char *path, float duration, char *text);
35 make_source (char *path, guint64 start, guint64 duration, gint priority,
38 char *uri = g_strdup_printf ("file://%s", path);
40 GESTimelineObject *ret =
41 GES_TIMELINE_OBJECT (ges_timeline_filesource_new (uri));
44 "start", (guint64) start,
45 "duration", (guint64) duration,
46 "priority", (guint32) priority, "in-point", (guint64) 0,
55 make_timeline (char *path, float duration, char *text)
57 GESTimeline *timeline;
58 GESTrack *trackv, *tracka;
59 GESTimelineLayer *layer1;
60 GESTimelineObject *srca;
61 GESTimelinePipeline *pipeline;
64 pipeline = ges_timeline_pipeline_new ();
66 ges_timeline_pipeline_set_mode (pipeline, TIMELINE_MODE_PREVIEW_VIDEO);
68 timeline = ges_timeline_new ();
69 ges_timeline_pipeline_add_timeline (pipeline, timeline);
71 trackv = ges_track_video_raw_new ();
72 ges_timeline_add_track (timeline, trackv);
74 tracka = ges_track_audio_raw_new ();
75 ges_timeline_add_track (timeline, tracka);
77 layer1 = GES_TIMELINE_LAYER (ges_timeline_layer_new ());
78 g_object_set (layer1, "priority", (gint32) 0, NULL);
80 if (!ges_timeline_add_layer (timeline, layer1))
83 aduration = (guint64) (duration * GST_SECOND);
84 srca = make_source (path, 0, aduration, 1, text);
85 ges_timeline_layer_add_object (layer1, srca);
91 main (int argc, char **argv)
95 GESTimelinePipeline *pipeline;
100 GOptionEntry options[] = {
101 {"duration", 'd', 0, G_OPTION_ARG_DOUBLE, &duration,
102 "duration of transition", "seconds"},
103 {"path", 'p', 0, G_OPTION_ARG_STRING, &path,
104 "path to file", "path"},
105 {"text", 't', 0, G_OPTION_ARG_STRING, &text,
106 "text to render", "text"},
110 ctx = g_option_context_new ("- transition between two media files");
111 g_option_context_add_main_entries (ctx, options, NULL);
112 g_option_context_add_group (ctx, gst_init_get_option_group ());
114 if (!g_option_context_parse (ctx, &argc, &argv, &err)) {
115 g_print ("Error initializing %s\n", err->message);
120 g_print ("%s", g_option_context_get_help (ctx, TRUE, NULL));
124 g_option_context_free (ctx);
128 pipeline = make_timeline (path, duration, text);
130 mainloop = g_main_loop_new (NULL, FALSE);
131 g_timeout_add_seconds ((duration) + 1, (GSourceFunc) g_main_loop_quit,
133 gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING);
134 g_main_loop_run (mainloop);