gstreamer serversink options (for mjpeg based solution)
Bram Van Steenlandt
bram at diomedia.be
Mon Feb 29 08:02:37 UTC 2016
Hi,
I'm writing a cctv viewing and recording app, the viewing and recording
part works but I would also like to "restream" the stream using
mod_python/apache in the http mjpeg format.
I previously used mplayer for this, I opened the stream and wrote to a
fifo and then read that from mod_python, I wasn't very efficient when
there were more users viewing (as it required an mplayer instance per
viewer, not per camera, viewing 16 cameras with two browsers was 32
mplayer proccesses).
Now, as I'm using gstreamer I would like to do something similar, I
first tried the tcpserversink but while this works ok it has an issue
where top cpu % goes up to 150% (from 40%) and it never goes down again,
even when you disconnect every tcp client, it does still work with cpu %
this high.
I looked online and found other people had similar issues when using the
tcpserversink
I also tried the udpsink but couldn't get that to work.
What are my best options, I've looked in to it and still see:
-appsink + write my own tcpserver, from what I can tell not many have
used this in python and the bindings may not be complete, I'm a bit
worried that adding that load to the program that already does viewing
and recording may be too much.
-fdsink and pipe that to another python program that will function as a
tcpserversink, this seems to be a decent solution as 16 cameras would
require 16 seperate python proccesses which will ease the load.
-shmsink but this seems a bit complicated, I'm unsure if I can use this
as if it was a tcp socket (from python).
Is there another option that I've missed and is better suited ?
Is there a simple fix to make the tcpserversink more efficient ? Is
there indeed an issue with tcpserversink or is my gst-launch constructed
very badly (esp. the part where I use two tee commands) ?
I'm using gstreamer 1.6.1 from python 2.7 on freebsd 10.2/amd64 and I'm
using the nvidia driver for viewing the cameras locally.
I'm using
gst-launch-1.0 rtspsrc name=src location=rtsp://x.x.x.x/v01 latency=100
! rtpjpegdepay ! tee name=a ! tee name=b ! jpegdec ! queue ! xvimagesink
a. ! queue ! multifilesink next-file=1 max-files=10 max-file-size=500000
location=/home/bram/recordings/tmp/cam1.%02d.avi b. ! queue !
tcpserversink port=4954
I did a lot of experimenting and this gst-launch is most efficient
(minus the tcpserversink) I could come up with, 2 cameras at 25fps
1920x1080 give a top value of 40% (on 2.6ghz xeon E5)
the camera uses mjpeg
the mjpeg stream is created in mod_python/apache (as this allows all
cameras plus some other stuff to be on the same "website" thus only
needing 1 port/ssl cert), all I need is an easy way to get jpeg frames
from the running gstreamer from within mod_python, tcpserversink was
ideal, except the cpu % issue.
I'm new to gstreamer and english is not my native language.
Thx in advance
Bram
More information about the gstreamer-devel
mailing list