Stream video through HAProxy

I want to transfer video from my webcam to many clients (all clients use html 5 video player).

Now I have this:

Server:

sudo gst-launch-0.10 tcpserversrc port = 1234 ! oggparse ! tcpserversink port = 1235

Sender:

ffmpeg -f video4linux2 -s 320x240 -i /dev/mycam -f alsa -i hw:1 -codec:v libtheora -qscale:v 5 -codec:a libvorbis -qscale:a 5 -f ogg http://localhost:1234

Recipient:

<video width="320" height="240" autoplay>
  <source src="http://localhost:1235" type="video/ogg">
  Your browser does not support the video tag.
</video>

He works.

Now I want to increase the number of webcams. Therefore, I need to increase the amount of gstreamer's. But I want to use only port 80 for communication between the server and clients, so I'm trying to use HAProxy.

HAProxy config: (only one webcam)

global
        maxconn 4096
        user workshop-staff
        group workshop-staff
        daemon
        log 127.0.0.1 local0 debug

defaults
        log     global
        mode    http
        option  httplog
        option  dontlognull
        retries 3
        option redispatch
        option http-server-close
        option forwardfor
        maxconn 2000
        timeout connect 5s
        timeout client  15min
        timeout server  15min
        option http-no-delay

frontend public
        bind *:80
        use_backend stream_input if { path_beg /stream_input }        
        use_backend stream_output if { path_beg /stream_output }

backend stream_input
        server stream_input1 localhost:1234

backend stream_output
        server stream_output1 localhost:1235

Server:

sudo gst-launch-0.10 tcpserversrc port = 1234 ! oggparse ! tcpserversink port = 1235

Sender:

ffmpeg -f video4linux2 -s 320x240 -i /dev/mycam -f alsa -i hw:1 -codec:v libtheora -qscale:v 5 -codec:a libvorbis -qscale:a 5 -f ogg http://localhost/stream_input

Recipient:

<video width="320" height="240" autoplay>
  <source src="http://localhost/stream_output" type="video/ogg">
  Your browser does not support the video tag.
</video>

But in this case, the HTML5 video player does not show anything .

If I changed the receiver to: (i.e. use localhost: 1235 instead of localhost / stream_output)

<video width="320" height="240" autoplay>
  <source src="http://localhost:1235" type="video/ogg">
  Your browser does not support the video tag.
</video>

It works. Can someone help me?

+4

All Articles