Created
July 3, 2015 19:41
-
-
Save sampsyo/c91b07c3a71c9fdad5c7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import gi | |
from gi.repository import GObject, Gst | |
import urllib | |
import sys | |
import os | |
gi.require_version('Gst', '1.0') | |
file_path = sys.argv[1] | |
GObject.threads_init() | |
Gst.init(None) | |
pipeline = Gst.Pipeline() | |
dec = Gst.ElementFactory.make("uridecodebin", None) | |
conv = Gst.ElementFactory.make("audioconvert", None) | |
sink = Gst.ElementFactory.make("fakesink", None) | |
uri = 'file://' + urllib.quote(os.path.abspath(file_path)) | |
dec.set_property("uri", uri) | |
pipeline.add(dec) | |
pipeline.add(conv) | |
pipeline.add(sink) | |
conv.link(sink) | |
pipeline.set_state(Gst.State.PLAYING) | |
print(pipeline.get_state(1000000000)) | |
success, length = dec.query_duration(Gst.Format.TIME) | |
print(success, length) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment