5 # Copyright (C) 2011 Thibault Saunier <thibault.saunier@collabora.co.uk>
6 # Copyright (C) 2011 Luis de Bethencourt <luis.debethencourt@collabora.com>
8 # This program is free software; you can redistribute it and/or
9 # modify it under the terms of the GNU Lesser General Public
10 # License as published by the Free Software Foundation; either
11 # version 2.1 of the License, or (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 # Lesser General Public License for more details.
18 # You should have received a copy of the GNU Lesser General Public
19 # License along with this program; if not, write to the
20 # Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 # Boston, MA 02111-1307, USA.
22 # This program is free software; you can redistribute it and/or modify
23 # it under the terms of the GNU General Public License as published by
24 # the Free Software Foundation; either version 3, or (at your option)
32 gobject.threads_init()
38 def __init__(self, uris):
39 # init ges to have debug logs
41 self.mainloop = glib.MainLoop()
43 timeline = ges.timeline_new_audio_video()
44 self.layer = ges.SimpleTimelineLayer()
45 timeline.add_layer(self.layer)
47 self.pipeline = ges.TimelinePipeline()
48 self.pipeline.add_timeline(timeline)
49 bus = self.pipeline.get_bus()
50 bus.set_sync_handler(self.bus_handler)
52 # all timeline objects except the last will have a transition at the end
54 self.add_timeline_object(n, True)
55 self.add_timeline_object(uris[-1], False)
57 def add_timeline_object(self, uri, do_transition):
58 filesource = ges.TimelineFileSource (uri)
59 filesource.set_duration(long (gst.SECOND * 5))
60 self.layer.add_object(filesource, -1)
63 transition = ges.TimelineStandardTransition("crossfade")
64 transition.duration = gst.SECOND * 2
65 self.layer.add_object(transition, -1)
67 def bus_handler(self, unused_bus, message):
68 if message.type == gst.MESSAGE_ERROR:
71 elif message.type == gst.MESSAGE_EOS:
78 if (self.pipeline.set_state(gst.STATE_PLAYING) == \
79 gst.STATE_CHANGE_FAILURE):
80 print "Couldn't start pipeline"
86 usage = "usage: %s URI-OF-VIDEO-1 ... URI-OF-VIDEO-n\n" % args[0]
89 sys.stderr.write(usage)
92 parser = optparse.OptionParser (usage=usage)
93 (options, args) = parser.parse_args ()
98 if __name__ == "__main__":
99 sys.exit(main(sys.argv))