pipelne.get_clock() returns None

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

pipelne.get_clock() returns None

Stuart Axon
Hi all,
   I'm using gstreamer 1.0 on python + having a go at getting network time working.


The code below is what I use to build the pipeline + play a video, the only thing I can think is that I need to manually set the clock, but all the examples on the net seem to grab it from the pipeline -


#!/usr/bin/python
 
# gst-launch-1.0 filesrc location=3.mp4 ! decodebin ! glimagesink
FILENAME="1.mp4"

import gi

gi.require_version('Gst', '1.0')
from gi.repository import GObject, Gst, GLib

Gst.init()
mainloop = GLib.MainLoop()

src = Gst.ElementFactory.make('filesrc', None)
src.set_property("location", FILENAME)

decode = Gst.ElementFactory.make('decodebin', 'decode')
sink = Gst.ElementFactory.make('glimagesink', None)

def decode_src_created(element, pad):
    pad.link(sink.get_static_pad('sink'))
   
decode.connect('pad-added', decode_src_created)

pipeline = Gst.Pipeline()
pipeline.add(src)
pipeline.add(decode)
pipeline.add(sink)

src.link(decode)

def quit():
    print("quit")
    pipeline.set_state(Gst.State.READY)
    mainloop.quit()

GLib.timeout_add_seconds(5, quit)

print("clock: ", pipeline.get_clock())

print("play")
pipeline.set_state(Gst.State.PLAYING)

print("start mainloop")
mainloop.run()
print("bye !")



_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: pipelne.get_clock() returns None

Arjen Veenhuizen
I think you have to wait until the pipeline is at least in PREROLLED state before you can retrieve a valid clock.
Reply | Threaded
Open this post in threaded view
|

Re: pipelne.get_clock() returns None

Stuart Axon
Cheers.

In case this is useful to anyone in the future:

I wasn't sure how synchronously to wait for the pipeline to become prerolled, while using GLib.MainLoop -  but was able to grab the system clock before the pipeline was prerolled, and set it like this:

>>> clock = Gst.SystemClock.obtain()
>>> pipeline.use_clock(clock)


I verified this was the same clock that the pipeline used, by watching for the 'new-clock' message on the bus


bus = pipeline.get_bus()

def on_message(bus, message):
    if pipeline.get_clock():
        print("on_message, type: %s" % message.type)
        clock = pipeline.get_clock()
        sysclock = Gst.SystemClock.obtain()
        print("sysclock, clock, clock == sysclock", sysclock, clock, sysclock == clock)
   
bus.add_signal_watch()
bus.connect("message::new-clock", on_message)
bus.add_watch(0, bus_call, mainloop) # 0 == GLib.PRIORITY_DEFAULT



On Tuesday, September 13, 2016 9:31 PM, Arjen Veenhuizen <[hidden email]> wrote:


I think you have to wait until the pipeline is at least in PREROLLED state
before you can retrieve a valid clock.



--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/pipelne-get-clock-returns-None-tp4679565p4679568.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel




_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel