简体   繁体   English

如何阻止Gstreamer尝试初始化X11

[英]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: 我一直在尝试创建一个想要从命令行运行的简单音频播放器,为此,我使用了Gstreamerpygst python绑定,到目前为止,我的代码如下所示:

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. 我可以毫无问题地播放音乐,但是我会摆脱这些警告,现在我假设Gstreamer库出于某种原因试图启动需要X11东西,但对于音频播放部分来说并不必要。 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 ? 我可以导入其他内容或传递某种标志来阻止Gstreamer尝试初始化X11吗?

EDIT 1 编辑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 编辑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. 好的, element(?) playbin器有点像现成的管道,其中包含一些与音频和视频相关的东西,很抱歉,我现在无法对其进行更好的解释。 However it seems that playbin initializes some elements(?) that tries to access X11 . 但是似乎playbin初始化了一些尝试访问X11 elements(?) 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. 我已经设法编辑了一些playbin elements(?)但没有一个可以解决X11警告。

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. 您应该能够在playbin的flag属性中禁用video标志。 Alternately, if you do need video and know which video sink you need, set the video-sink property accordingly. 或者,如果您确实需要视频并且知道需要哪个视频接收器,请相应地设置video-sink属性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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