2

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.

Daniel Figueroa
  • 10,348
  • 5
  • 44
  • 66

1 Answers1

1

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.

Hasturkun
  • 35,395
  • 6
  • 71
  • 104
  • Thanks for your suggestion, I'm completely new to gstreamer so I'm not sure if I followed you correctly. But if I understood things correctly that only disables the automatic enabling of video-streaming, which is a good thing disabling in my case since I don't need it. – Daniel Figueroa Mar 24 '13 at 13:51
  • Ok. I just realized that this is not an answer to your question. I initially assumed that a video sink was being tried and generated the warning, This does not appear to be the case. Could you run `gst-inspect` and grep for `hal`? It's the only gstreamer plugin I see that directly references DBUS. – Hasturkun Mar 24 '13 at 14:02
  • I ran `gst-inspect-0.10 | grep hal` and that outputs nothing. From my understanding so far, shouldn't it exist something else that I can pass instead of `playbin` to the element factory that only enalbes audio streams? – Daniel Figueroa Mar 24 '13 at 14:06
  • `playbin` should do that. (as an aside, I suggest you use `playbin2` instead. but I doubt that will make the warning go away). I'll be deleting this answer shortly. – Hasturkun Mar 24 '13 at 14:14
  • I still think that even though this isn't the correct answer it points out that you can disable the video-streaming. Our discussion might be useful for others. Oh and thanks a ton for your time! :) – Daniel Figueroa Mar 24 '13 at 14:19