/usr/share/gst-python/0.10/examples/gstfile.py is in python-gst0.10-dev 0.10.22-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | #!/usr/bin/env python
# -*- Mode: Python -*-
# vi:si:et:sw=4:sts=4:ts=4
# gstfile.py
# (c) 2005 Edward Hervey <edward at fluendo dot com>
# Discovers and prints out multimedia information of files
# This example shows how to use gst-python:
# _ in an object-oriented way (Discoverer class)
# _ subclassing a gst.Pipeline
# _ and overidding existing methods (do_iterate())
import os
import sys
import gobject
gobject.threads_init()
import pygst
pygst.require('0.10')
from gst.extend.discoverer import Discoverer
class GstFile:
"""
Analyses one or more files and prints out the multimedia information of
each file.
"""
def __init__(self, files):
self.files = files
self.mainloop = gobject.MainLoop()
self.current = None
def run(self):
gobject.idle_add(self._discover_one)
self.mainloop.run()
def _discovered(self, discoverer, ismedia):
discoverer.print_info()
self.current = None
if len(self.files):
print "\n"
gobject.idle_add(self._discover_one)
def _discover_one(self):
if not len(self.files):
gobject.idle_add(self.mainloop.quit)
return False
filename = self.files.pop(0)
if not os.path.isfile(filename):
gobject.idle_add(self._discover_one)
return False
print "Running on", filename
# create a discoverer for that file
self.current = Discoverer(filename)
# connect a callback on the 'discovered' signal
self.current.connect('discovered', self._discovered)
# start the discovery
self.current.discover()
return False
def main(args):
if len(args) < 2:
print 'usage: %s files...' % args[0]
return 2
gstfile = GstFile(args[1:])
gstfile.run()
if __name__ == '__main__':
sys.exit(main(sys.argv))
|