semofa
Posts: 21
Joined: Mon Jun 01, 2015 8:18 pm

Python 'DBUS' error

Wed Jul 29, 2015 12:34 am

I have two raspberry pi. one of them stream video and audio and other one record video and audio. both of them use Gstreamer.
on the second Raspberry Pi I write a Python program that record video and audio. but when I run the program on terminal I get the following error :

Code: Select all

** (DO2.py:7495): WARNING **: Error retrieving accessibility bus address: org.freedesktop.DBus.Error.ServiceUnknown: The name org.a11y.Bus was not provided by any .service files

** (DO2.py:7495): WARNING **: Can't load fallback CSS resource: Failed to import: The resource at '/org/gnome/adwaita/gtk-fallback.css' does not exist

** (DO2.py:7495): WARNING **: Can't load fallback CSS resource: Failed to import: The resource at '/org/gnome/adwaita/gtk-fallback.css' does not exist
prepare-window-handle

(DO2.py:7495): GStreamer-WARNING **: gstpad.c:4506:store_sticky_event:<gdepay:src> Sticky event misordering, got 'segment' before 'caps'

(DO2.py:7495): GStreamer-WARNING **: gstpad.c:4506:store_sticky_event:<rdepay:sink> Sticky event misordering, got 'segment' before 'caps'
Segmentation fault

my python program wrked fin in my laptop that has Ubuntu. but does not work on Raspberry PI.
and here is my Python Program:

Code: Select all

#!/usr/bin/python3

from os import path

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

# Needed for window.get_xid(), xvimagesink.set_window_handle(), respectively:
from gi.repository import GdkX11, GstVideo


GObject.threads_init()
Gst.init(None)


class Player(object):
    def __init__(self):

        
        self.window = Gtk.Window()
        self.window.connect('destroy', self.quit)
        self.window.set_default_size(800, 450)

        self.drawingarea = Gtk.DrawingArea()
        self.window.add(self.drawingarea)

        # Create GStreamer pipeline
        self.pipeline = Gst.Pipeline()
        self.pipeline_A = Gst.Pipeline()

        # Create bus to get events from GStreamer pipeline
        self.bus = self.pipeline.get_bus()
        self.bus.add_signal_watch()
        self.bus.connect('message::eos', self.on_eos)
        self.bus.connect('message::error', self.on_error)

        # This is needed to make the video output in our DrawingArea:
        self.bus.enable_sync_message_emission()
        self.bus.connect('sync-message::element', self.on_sync_message)
        

        
##############################################################################
#VIDEO Pipeline
#|
#|
#V
##############################################################################
        self.tcpsrc = Gst.ElementFactory.make('tcpclientsrc','tcpsrc')
        self.tcpsrc.set_property("host", '192.168.1.9')
        self.tcpsrc.set_property("port", 5000)

        self.gdepay = Gst.ElementFactory.make('gdpdepay', 'gdepay')
        

        self.rdepay = Gst.ElementFactory.make('rtph264depay', 'rdepay')

        self.avdec = Gst.ElementFactory.make('avdec_h264', 'avdec')

        self.vidconvert = Gst.ElementFactory.make('videoconvert', 'vidconvert')
        
        self.asink = Gst.ElementFactory.make('autovideosink', 'asink')
        self.asink.set_property('sync', False)
        #self.asink.set_property('emit-signals', True)
        #self.set_property('drop', True)

        self.pipeline.add(self.tcpsrc)
        self.pipeline.add(self.gdepay)
        self.pipeline.add(self.rdepay)
        self.pipeline.add(self.avdec)
        self.pipeline.add(self.vidconvert)
        self.pipeline.add(self.asink)

        self.tcpsrc.link(self.gdepay)
        self.gdepay.link(self.rdepay)
        self.rdepay.link(self.avdec)
        self.avdec.link(self.vidconvert)
        self.vidconvert.link(self.asink)
##############################################################################
#^
#|
#|
#VIDEO Pipeline
##############################################################################


##############################################################################
#AUDIO Pipeline
#|
#|
#V
##############################################################################

        self.udpsrc = Gst.ElementFactory.make('udpsrc', 'udpsrc')
        self.udpsrc.set_property("port",5001)
        audioCaps = Gst.Caps.from_string("application/x-rtp")
        self.udpsrc.set_property("caps", audioCaps)

        self.queue = Gst.ElementFactory.make('queue', 'queue')
        

        self.rtppcmudepay = Gst.ElementFactory.make('rtppcmudepay', 'rtppcmudepay')

        self.mulawdec = Gst.ElementFactory.make('mulawdec', 'mulawdec')

        self.audioconvert = Gst.ElementFactory.make('audioconvert', 'audioconvert')
        
        self.autoaudiosink = Gst.ElementFactory.make('autoaudiosink', 'autoaudiosink')
        self.autoaudiosink.set_property('sync', False)

        self.pipeline_A.add(self.udpsrc)
        self.pipeline_A.add(self.queue)
        self.pipeline_A.add(self.rtppcmudepay)
        self.pipeline_A.add(self.mulawdec)
        self.pipeline_A.add(self.audioconvert)
        self.pipeline_A.add(self.autoaudiosink)

        self.udpsrc.link(self.queue)
        self.queue.link(self.rtppcmudepay)
        self.rtppcmudepay.link(self.mulawdec)
        self.mulawdec.link(self.audioconvert)
        self.audioconvert.link(self.autoaudiosink)

##############################################################################
#^
#|
#|
#AUDIO Pipeline
##############################################################################

    def run(self):
        self.window.show_all()
        # You need to get the XID after window.show_all().  You shouldn't get it
        # in the on_sync_message() handler because threading issues will cause
        # segfaults there.
        self.xid = self.drawingarea.get_property('window').get_xid()
        self.pipeline.set_state(Gst.State.PLAYING)
        self.pipeline_A.set_state(Gst.State.PLAYING)
        Gtk.main()
    
    def quit(self, window):
        self.pipeline.set_state(Gst.State.NULL)
        Gtk.main_quit()

    def on_sync_message(self, bus, msg):
        if msg.get_structure().get_name() == 'prepare-window-handle':
            print('prepare-window-handle')
            msg.src.set_window_handle(self.xid)

    def on_eos(self, bus, msg):
        print('on_eos(): seeking to start of video')
        self.pipeline.seek_simple(
            Gst.Format.TIME,        
            Gst.SeekFlags.FLUSH | Gst.SeekFlags.KEY_UNIT,
            0
        )

    def on_error(self, bus, msg):
        print('on_error():', msg.parse_error())

    
p = Player()
p.run()

Return to “General discussion”