简体   繁体   中英

How to stop Gstreamer from trying to initialize X11

I've been trying to create a simple audio-player which i want to run from the commandline, for this I've used Gstreamer and the pygst python bindings and my code so far looks like this:

import pygst
pygst.require('0.10')
import gst
import os

class Player(object):
    mp3stream = "http://http-live.sr.se/p1-mp3-192"

    def __init__(self):
        self.pipeline = gst.Pipeline("RadioPipe")
        self.player = gst.element_factory_make("playbin", "player")
        self.pipeline.add(self.player)

        self.player.set_property('uri', self.mp3stream)
        self.pipeline.set_state(gst.STATE_PLAYING)

player = Player()

while 1:
    if(1 == 2):
        break    

Now for some reason, when I run this code I get the following warnings:

** (radio.py:7803): WARNING **: Command line `dbus-launch --autolaunch=f12629ad79391c6f12cbbc1a50ccbcc8 --binary-syntax --close-stderr' exited with non-zero exit status 1: Autolaunch error: X11 initialization failed.\n

I can play music without a problem, but I would very much get rid of these warnings, now I assume that the Gstreamer library for some reason tries to start something that requires X11 but isn't necessary for the audioplaying part. Any comments on the validity of this assumption are most welcome.

Can I import something else or pass some sort of flag to stop Gstreamer from trying to initialize X11 ?

EDIT 1

I've tried adding this:

fakesink = gst.element_factory_make("fakesink", "fakesink")
self.player.set_property("video-sink", fakesink)

Which according to the documentation the above code will disable the automatic enabling of video-streaming. This does however not fix my problem with the warnings.

EDIT 2

Okay so the element(?) playbin is something like a ready-made piping of several audio and video related stuff, I'm sorry I can't explain it better for now. However it seems that playbin initializes some elements(?) that tries to access X11 . I'm guessing that since I'm not playing anything videorelated it doesn't crash. I've managed to edit some of the playbin elements(?) but none of them fixes the X11 warning.

The current code looks like this:

self.pipeline = gst.Pipeline("RadioPipe")

self.player = gst.element_factory_make("playbin", "player")
pulse = gst.element_factory_make("pulsesink", "pulse")
fakesink = gst.element_factory_make("fakesink", "fakesink")

self.player.set_property('uri', channel)
self.player.set_property("audio-sink", pulse)
self.player.set_property("video-sink", fakesink)

self.pipeline.add(self.player)

The questionmark after element has to do with me not being sure that is the correct wording.

You should be able to disable the video flag in playbin's flag properties. Alternately, if you do need video and know which video sink you need, set the video-sink property accordingly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM