X-Git-Url: https://git.ao2.it/experiments/gstreamer.git/blobdiff_plain/d6c6f1da71c2d875f82a829c63af0a6131b83932..fea9aded03f795cfea3e1710a5d1024d41895720:/python/gst-trick-mode.py diff --git a/python/gst-trick-mode.py b/python/gst-trick-mode.py index e50e252..45e7af2 100755 --- a/python/gst-trick-mode.py +++ b/python/gst-trick-mode.py @@ -1,5 +1,7 @@ #!/usr/bin/env python - +# +# A simple "trick-mode" player to play a file at a given speed rate. +# # Get a test sample with: # youtube-dl -t http://www.youtube.com/watch?v=yWa-YXiSk2Y @@ -15,12 +17,11 @@ GObject.threads_init() class Player: - def __init__(self, filename, rate): - self._filename = filename + def __init__(self, uri, rate): self._rate = rate self._player = Gst.ElementFactory.make("playbin", "player") - self._player.set_property("uri", filename) + self._player.set_property("uri", uri) bus = self._player.get_bus() bus.add_signal_watch() @@ -71,17 +72,16 @@ class Player: def main(args): def usage(): - sys.stdout.write("usage: %s \n" % args[0]) + sys.stdout.write("usage: %s \n" % args[0]) - if len(args) != 2: + if len(args) != 3: usage() sys.exit(1) - if not Gst.uri_is_valid(args[1]): - sys.stderr.write("Error: Invalid URI: %s\n" % args[1]) - sys.exit(1) + uri = Gst.filename_to_uri(args[1]) + rate = float(args[2]) - player = Player(args[1], 3.0) + player = Player(uri, rate) player.run() if __name__ == '__main__':