gstreamer python appsrc and mp3 files in python
Josef Novak
josef.robert.novak at gmail.com
Sun Aug 21 21:17:57 UTC 2016
Hi, In fact it looks like the problem was that the mp3 files I was creating
with sox for testing were invalid/uninterpretable. After switching to lame
to create the test files, the pipeline works fine. -Joe
On Sun, Aug 21, 2016 at 5:53 PM, Josef Novak <josef.robert.novak at gmail.com>
wrote:
> Hi,
>
> I am trying to setup a pipeline that will accept mp3 input to convert to
> raw, using the appsrc source, and the python bindings.
>
> In the command line, either of these work fine:
>
>
> $ gst-launch-1.0 -v -m filesrc location=test/1-dual-30s.l.mp3 \
> ! decodebin ! audioconvert ! audioresample \
> ! audio/x-raw,format=S16LE,rate=8000,channels=1 \
> ! filesink location=out.raw
>
> or
>
> $ cat test/1-dual-30s.l.mp3 | gst-launch-1.0 -v -m fdsrc fd=0 \
> ! decodebin ! audioconvert ! audioresample \
> ! audio/x-raw,format=S16LE,rate=8000,channels=1 \
> ! filesink location=out.raw
>
> however, when I try to replicate this with 'appsrc' and the python bindings:
> -----------------------------
> class DecodeToHTTPStreamPipeline () :
> def __init__ (self, http_conf, blocksize, loop) :
> self.HTTPClient = self._InitClient (http_conf, blocksize)
> self.blocksize = blocksize
> self.pipeline = gst.Pipeline ()
>
> self.bus = self.pipeline.get_bus ()
> self.bus.add_signal_watch ()
> self.bus.enable_sync_message_emission ()
> self.bus.connect ('message::eos', self._OnEOS)
> self.bus.connect ('message::tag', self._OnTag)
> self.bus.connect ('message::error', self._OnError)
>
> self.audiosource = gst.ElementFactory.make ('appsrc', 'appsrc')
> self.audiosource.set_property ("is-live", True)
> self.decodebin = gst.ElementFactory.make ('decodebin', 'decodebin')
> self.decodebin.connect ('pad-added', self._OnNewDecodedPad)
>
> self.audioconvert = gst.ElementFactory.make ('audioconvert', 'audioconvert')
> self.audioresample = gst.ElementFactory.make ('audioresample', 'audioresample')
> self.capsfilter = gst.ElementFactory.make ('capsfilter',
> 'audio/x-raw,format=S16LE,rate=8000,channels=1')
>
> self.audiosink = gst.ElementFactory.make ('appsink', 'appsink')
> self.audiosink.set_property ("emit-signals", True)
> self.audiosink.set_property ('drop', True)
> self.audiosink.set_property ('sync', False)
> self.audiosink.connect ('new-sample', self._OnNewBuffer, self.audiosink)
>
> if (not (self.pipeline and self.audiosource and self.decodebin and \
> self.audioconvert and self.audioresample and self.audiosink)) :
> print "Error with configuration. Quitting."
> sys.exit (-1)
>
> self.pipeline.add (self.audiosource)
> self.pipeline.add (self.decodebin)
> self.pipeline.add (self.audioconvert)
> self.pipeline.add (self.audioresample)
> self.pipeline.add (self.capsfilter)
> self.pipeline.add (self.audiosink)
> #self.SetOutLocation (outlocation)
>
> self.audiosource.link (self.decodebin)
> self.decodebin.link (self.audioconvert)
> self.audioconvert.link (self.audioresample)
> self.audioresample.link (self.capsfilter)
> self.capsfilter.link (self.audiosink)
>
> self.loop = loop
> self.pipeline.set_state (gst.State.PLAYING)
> -----------------------------
>
> I end up with a pipeline that works fine for a range of codecs: .wav, .flac, etc, but it fails with .mp3 files in the sense that
>
> it does not seem to detect them as .mp3 files, and the output is junk.
>
> I noted that even on yakkety, gst-inspect lists avdec_mp3 is ranked as 'marginal', is it possible that this is the problem?
>
> --------------------
> $ gst-inspect-1.0 avdec_mp3
> Factory Details:
> Rank marginal (64)
> Long-name libav MP3 (MPEG audio layer 3) decoder
>
> ----------------------
>
> Is there a work around or reconfiguration for the python bindings that does not involve recompiling everything from source?
>
> A different combination of elements for .mp3 would be no problem, but I could not find any that worked (including 'mad' or 'mpg123').
>
> Best regards
>
> -Joe
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20160821/736443de/attachment-0001.html>
More information about the gstreamer-devel
mailing list