3 # vi:si:et:sw=4:sts=4:ts=4
6 # (c) 2005 Edward Hervey <edward at fluendo dot com>
7 # Discovers and prints out multimedia information of files
9 # This example shows how to use gst-python:
10 # _ in an object-oriented way (Discoverer class)
11 # _ subclassing a gst.Pipeline
12 # _ and overidding existing methods (do_iterate())
18 gobject.threads_init()
23 from gst.extend.discoverer import Discoverer
27 Analyses one or more files and prints out the multimedia information of
31 def __init__(self, files):
33 self.mainloop = gobject.MainLoop()
37 gobject.idle_add(self._discover_one)
40 def _discovered(self, discoverer, ismedia):
41 discoverer.print_info()
45 gobject.idle_add(self._discover_one)
47 def _discover_one(self):
48 if not len(self.files):
49 gobject.idle_add(self.mainloop.quit)
51 filename = self.files.pop(0)
52 if not os.path.isfile(filename):
53 gobject.idle_add(self._discover_one)
55 print "Running on", filename
56 # create a discoverer for that file
57 self.current = Discoverer(filename)
58 # connect a callback on the 'discovered' signal
59 self.current.connect('discovered', self._discovered)
61 self.current.discover()
66 print 'usage: %s files...' % args[0]
69 gstfile = GstFile(args[1:])
72 if __name__ == '__main__':
73 sys.exit(main(sys.argv))