I'm building streaming application in python with gstreamer.
The application writes data to rtmpsink and to filesink using a tee
element. Starting and streaming works fine in ideal environment (local network) but what to do if there is a disconnect with the streaming server for example? I'm trying to figure out how to keep the pipeline running and thus keep writing to filesink after error occurs...
What I'm trying to archive:
Question(s):
Is it possible to archive what I'm trying to do?
How can it be archived (dynamic pipeline / probes / extra elements )?
Any explanation, example or point to right direction will be very much appreciated.
note:
Gst version: gstreamer 1.3.90 (rtmpsink, faac, x264enc)
OS: ubuntu 14.04 LTS
Streaming server: wowza 4.x
Test application (code): link
Pipeline after startup(OK): link
Pipeline after rtmpsink error(Failed to write data): link
Log snippet after rtmpsink error(Failed to write data): link
I'm not sure how reliable a system you'll get with a single pipeline on this. What I'd recommend doing is creating a two stage process:
1) audio -> encode -> tee -> filesink
-> shmsink
2) shmsrc -> mux -> rtmpsink
Then create a wrapper script for the second pipeline. Here's a sample of how to use these elements with a videotestsrc. Note that the caps are really important--they have to be sufficiently detailed to know what's coming in over the shared memory.
gst-launch-1.0 videotestsrc ! tee name=t ! queue ! videoconvert ! ximagesink t. ! video/x-raw,width=400,height=400,format=BGRA ! shmsink wait-for-connection=false socket-path=/tmp/shr
gst-launch-1.0 shmsrc socket-path=/tmp/shr ! video/x-raw,width=400,height=400,format=BGRA,framerate=30/1 ! videoconvert ! ximagesink
You could also try this approach with TCP/UDP instead of shared memory. I don't have faac plugin installed but the pipeline would probably be something like this:
audio -> faac -> rtpmp4apay -> udpsink host=localhost port=1919
udpsrc port=1919 -> rtpmp4adepay -> mux -> rtmpsink