problem with running my program in python - Raspberry Pi Forums
i wrote following code on computer , it's worked.
)
when want run on raspbian, following error:
please help
code: select all
#!/usr/bin/python3 os import path import gi gi.require_version('gst', '1.0') gi.repository import gobject, gst, gtk # needed window.get_xid(), xvimagesink.set_window_handle(), respectively: 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 events 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) # needed make 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.12') 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() # need xid after window.show_all(). shouldn't # in on_sync_message() handler because threading issues 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 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(
when want run on raspbian, following error:
code: select all
** (do.py:3394): warning **: error retrieving accessibility bus address: org.freedesktop.dbus.error.serviceunknown: name org.a11y.bus not provided .service files error:root:could not find typelib gstvideo traceback (most recent call last): file "do.py", line 10, in <module> gi.repository import gdkx11, gstvideo importerror: cannot import name gstvideo
raspberrypi
Comments
Post a Comment