Question

I am trying to port the following GStreamer command into a python program:

gst-launch-0.10 -v -m v4l2src ! queue ! ffmpegcolorspace ! queue ! x264enc pass=pass1 threads=0 bitrate=1536 tune=zerolatency ! queue ! flvmux name=mux  pulsesrc ! queue max-size-bytes=134217728 max-size-time=20000000000 max-size-buffers=1000 ! audioconvert ! lame ! audio/mpeg ! queue ! mux. mux. ! queue ! rtmpsink location='rtmp://x.x.x.x/live/myStream'

With this command it is possible to record and watch the live stream when streaming to a wowza server. But I am having some troubles porting this command to python. Especially the RTMP sink seems to cause troubles (because it is working with a filesink):

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

    self.src = gst.parse_launch("v4l2src")
    self.pipeline.add(self.src)

    self.videoenc = make_bin("(name=videoenc queue ! ffmpegcolorspace ! queue ! x264enc pass=pass1 threads=0 bitrate=1536 tune=zerolatency ! queue )")
    self.pipeline.add(self.videoenc)

    self.audio2src = gst.parse_launch("pulsesrc")
    self.pipeline.add(self.audio2src)

    self.audio2 = make_bin("(name=audio2 queue max-size-bytes=134217728 max-size-time=20000000000 max-size-buffers=1000 ! audioconvert ! lame ! audio/mpeg ! queue)")
    self.pipeline.add(self.audio2)
    self.audio2src.link(self.audio2)

    self.flvmux = gst.parse_launch("flvmux name=flvmux")
    self.pipeline.add(self.flvmux)
    self.videoenc.link(self.flvmux)
    self.audio2.link(self.flvmux)

    self.queue1 = gst.parse_launch("queue")
    self.rtmpsink = gst.parse_launch("rtmpsink location='rtmp://192.168.1.11/live/myStream'")
    self.pipeline.add(self.queue1, self.rtmpsink)
    gst.element_link_many(self.flvmux, self.queue1, self.rtmpsink)

    self.pipeline.set_state(gst.STATE_PLAYING)

here is the output:

    PAUSED: /GstPipeline:diepipeline/GstQueue:queue5 (__main__.GstQueue)
PAUSED: /GstPipeline:diepipeline/GstFlvMux:flvmux (__main__.GstFlvMux)
PAUSED: /GstPipeline:diepipeline/GstBin:audio2/GstQueue:queue4 (__main__.GstQueue)
PAUSED: /GstPipeline:diepipeline/GstBin:audio2/GstCapsFilter:capsfilter0 (__main__.GstCapsFilter)
PAUSED: /GstPipeline:diepipeline/GstBin:audio2/GstLame:lame0 (__main__.GstLame)
PAUSED: /GstPipeline:diepipeline/GstBin:audio2/GstAudioConvert:audioconvert0 (__main__.GstAudioConvert)
PAUSED: /GstPipeline:diepipeline/GstBin:audio2/GstQueue:queue3 (__main__.GstQueue)
PAUSED: /GstPipeline:diepipeline/GstBin:audio2 (gst.Bin)
PAUSED: /GstPipeline:diepipeline/GstBin:videoenc/GstQueue:queue2 (__main__.GstQueue)
PAUSED: /GstPipeline:diepipeline/GstBin:videoenc/GstX264Enc:x264enc0 (__main__.GstX264Enc)
PAUSED: /GstPipeline:diepipeline/GstBin:videoenc/GstQueue:queue1 (__main__.GstQueue)
PAUSED: /GstPipeline:diepipeline/GstBin:videoenc/GstFFMpegCsp:ffmpegcsp0 (__main__.GstFFMpegCsp)
PAUSED: /GstPipeline:diepipeline/GstBin:videoenc/GstQueue:queue0 (__main__.GstQueue)
PAUSED: /GstPipeline:diepipeline/GstBin:videoenc (gst.Bin)
PAUSED: /GstPipeline:diepipeline/GstPulseSrc:pulsesrc0 (__main__.GstPulseSrc)
PAUSED: /GstPipeline:diepipeline/GstDecklinkSrc:src (__main__.GstDecklinkSrc)
PAUSED: /GstPipeline:diepipeline (gst.Pipeline)
PAUSED: /GstPipeline:diepipeline/GstFileSink:filesink0 (__main__.GstFileSink)

Any idea what might cause this problem? Thanks!

Was it helpful?

Solution

Ok, after hours of trying out different things I found the flaw in my code.

Had to remove the single quote in my rtmp-url:

from

 self.rtmpsink = gst.parse_launch("rtmpsink location='rtmp://x.x.x.x/live/myStream'")

to

 self.rtmpsink = gst.parse_launch("rtmpsink location=rtmp://x.x.x.x/live/myStream")

Sometimes the simplest things are the ones that cost you the most time...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top