Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6574017
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:12:25+00:00 2026-05-25T15:12:25+00:00

I’m trying to work with GStreamer. I’m following a tutorial ( http://pygstdocs.berlios.de/pygst-tutorial/pipeline.html ) that

  • 0

I’m trying to work with GStreamer. I’m following a tutorial (http://pygstdocs.berlios.de/pygst-tutorial/pipeline.html) that gives me the following code:

#!/usr/bin/env python

import sys, os
import pygtk, gtk, gobject
import pygst
pygst.require("0.10")
import gst

class GTK_Main:

    def __init__(self):
        window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        window.set_title("Mpeg2-Player")
        window.set_default_size(500, 400)
        window.connect("destroy", gtk.main_quit, "WM destroy")
        vbox = gtk.VBox()
        window.add(vbox)
        hbox = gtk.HBox()
        vbox.pack_start(hbox, False)
        self.entry = gtk.Entry()
        hbox.add(self.entry)
        self.button = gtk.Button("Start")
        hbox.pack_start(self.button, False)
        self.button.connect("clicked", self.start_stop)
        self.movie_window = gtk.DrawingArea()
        vbox.add(self.movie_window)
        window.show_all()

        self.player = gst.Pipeline("player")
        source = gst.element_factory_make("filesrc", "file-source")
        demuxer = gst.element_factory_make("oggdemux", "demuxer")
        demuxer.connect("pad-added", self.demuxer_callback)
        self.video_decoder = gst.element_factory_make("theoradec", "video-decoder")
        self.audio_decoder = gst.element_factory_make("mad", "audio-decoder")
        audioconv = gst.element_factory_make("audioconvert", "converter")
        audiosink = gst.element_factory_make("autoaudiosink", "audio-output")
        videosink = gst.element_factory_make("autovideosink", "video-output")
        self.queuea = gst.element_factory_make("queue", "queuea")
        self.queuev = gst.element_factory_make("queue", "queuev")
        colorspace = gst.element_factory_make("ffmpegcolorspace", "colorspace")

        self.player.add(source, demuxer, self.video_decoder, self.audio_decoder, audioconv,
            audiosink, videosink, self.queuea, self.queuev, colorspace)
        gst.element_link_many(source, demuxer)
        gst.element_link_many(self.queuev, self.video_decoder, colorspace, videosink)
        gst.element_link_many(self.queuea, self.audio_decoder, audioconv, audiosink)

        bus = self.player.get_bus()
        bus.add_signal_watch()
        bus.enable_sync_message_emission()
        bus.connect("message", self.on_message)
        bus.connect("sync-message::element", self.on_sync_message)

    def start_stop(self, w):
        if self.button.get_label() == "Start":
            filepath = self.entry.get_text()
            if os.path.isfile(filepath):
                self.button.set_label("Stop")
                self.player.get_by_name("file-source").set_property("location", filepath)
                self.player.set_state(gst.STATE_PLAYING)
        else:
            self.player.set_state(gst.STATE_NULL)
            self.button.set_label("Start")

    def on_message(self, bus, message):
        t = message.type
        if t == gst.MESSAGE_EOS:
            self.player.set_state(gst.STATE_NULL)
            self.button.set_label("Start")
        elif t == gst.MESSAGE_ERROR:
            err, debug = message.parse_error()
            print "Error: %s" % err, debug
            self.player.set_state(gst.STATE_NULL)
            self.button.set_label("Start")

    def on_sync_message(self, bus, message):
        if message.structure is None:
            return
        message_name = message.structure.get_name()
        if message_name == "prepare-xwindow-id":
            imagesink = message.src
            imagesink.set_property("force-aspect-ratio", True)
            gtk.gdk.threads_enter()
            imagesink.set_xwindow_id(self.movie_window.window.xid)
            gtk.gdk.threads_leave()

    def demuxer_callback(self, demuxer, pad):
        if pad.get_property("template").name_template == "video_%02d":
            qv_pad = self.queuev.get_pad("sink")
            pad.link(qv_pad)
        elif pad.get_property("template").name_template == "audio_%02d":
            qa_pad = self.queuea.get_pad("sink")
            pad.link(qa_pad)

GTK_Main()
gtk.gdk.threads_init()
gtk.main()

I’m getting the following error when I try and play a .ogv file.

videotest.py:88: Warning: g_object_set_qdata: assertion `G_IS_OBJECT
(object)’ failed if pad.get_property(“template”).name_template ==
“video_%02d”: Traceback (most recent call last): File
“videotest.py”, line 88, in demuxer_callback
if pad.get_property(“template”).name_template == “video_%02d”:
AttributeError: ‘NoneType’ object has no attribute ‘name_template’
Traceback (most recent call last): File “videotest.py”, line 88, in
demuxer_callback
if pad.get_property(“template”).name_template == “video_%02d”:
AttributeError: ‘NoneType’ object has no attribute ‘name_template’

I really need to be able to play video. How do I fix this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T15:12:26+00:00Added an answer on May 25, 2026 at 3:12 pm

    It is not reliable to determine pad type by it’s template name because it does not always have this property.

    It’s better to check capabilities. Here is diff:

    @@ -85,10 +85,11 @@
                 gtk.gdk.threads_leave()
    
         def demuxer_callback(self, demuxer, pad):
    -        if pad.get_property("template").name_template == "video_%02d":
    +        typ = pad.get_caps()[0].get_name()
    +        if typ.startswith("video"):
                 qv_pad = self.queuev.get_pad("sink")
                 pad.link(qv_pad)
    -        elif pad.get_property("template").name_template == "audio_%02d":
    +        elif typ.startswith("audio"):
                 qa_pad = self.queuea.get_pad("sink")
                 pad.link(qa_pad)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to create an if statement in PHP that prevents a single post
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
That's pretty much it. I'm using Nokogiri to scrape a web page what has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.