[gst-devel] getting display dimensions for a theora video with pygst

Jason Gerard DeRose jderose at jasonderose.org
Tue Nov 7 18:23:49 CET 2006


One way to do this is with a handler for the 'notify::caps' signal
emitted by the 'src' pad on your theoradec element, as this excerpt shows:

    theoradec.get_pad('src').connect('notify::caps', self._on_notify_caps)


    def _on_notify_caps(self, pad, args):
        caps = pad.get_negotiated_caps()
        if caps == None:
        width = caps[0]['width']
        height = caps[0]['height']
        frac = caps[0]['pixel-aspect-ratio']
        aspect = float(width) / height * frac.num / frac.denom

If you are writing a player, I highly recommend using the high level
'playbin' element as your backend.  You can get the above information (I
 think) from the 'stream-info' property on your playbin.  However, your
playbin must be at gst.STATE_PAUSED or above to get anything useful.
Also, depending upon what elements your playbin has loaded, the state
changes might be asynchronous, so you need to do something like this:

if gst.STATE_CHANGE_ASYNC == playbin.set_state(gst.STATE_PAUSED):
    playbin.get_state(1000) # Wait for up to 1 second
info = playbin.get_property('stream-info')


Erik Blankinship wrote:
> Using pygst, I have loaded in an ogg theora video and would like to know the video's dimensions or at least the video's aspect ratio.
> I do not know how to do this using pygst.
> This sample code from the manual seems to describe what I want to do, but I am not sure how to make calls like these work with pygst:
> http://gstreamer.freedesktop.org/data/doc/gstreamer/head/manual/html/section-caps-api.html#section-caps-metadata
> If anyone can help out, it would be much appreciated.
> Thanks,
> Erik
> -------------------------------------------------------------------------
> Using Tomcat but need to do more? Need to support web services, security?
> Get stuff done quickly with pre-integrated technology to make your job easier
> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel

More information about the gstreamer-devel mailing list