通过HAProxy进行视频流传输

时间:2015-01-21 12:16:12

标签: ffmpeg html5-video gstreamer haproxy

我想将视频从我的网络摄像头流式传输到许多客户端(所有客户端都使用html 5视频播放器)。

现在我有了这个:

服务器:

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

发信人:

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

接收器:

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

有效。

现在我想增加网络摄像头的数量。因此,我需要增加gstreamer的数量。但是,我想只使用端口80在服务器和客户端之间进行通信,因此我尝试使用HAProxy。

HAProxy配置:(只有一个网络摄像头)

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

服务器:

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

发信人:

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

接收器:

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

但是,在这种情况下, HTML5视频播放器不会显示任何内容

如果我将接收器更改为:(即使用localhost:1235而不是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>

有效。有人能帮助我吗?

0 个答案:

没有答案