A
A
Alexander Batalov2012-12-05 16:28:39
Nginx
Alexander Batalov, 2012-12-05 16:28:39

VLC + Nginx

I want to use Nginx as a server for distributing a stream from vlc.
I send a video stream from the local machine to the broadcast server through the ssh tunnel.
Nginx config is like this:

server {
        listen   8083;

        location = /stream.flv {
            proxy_pass         http://localhost:8082/;
            proxy_redirect     off;

            proxy_set_header   Host             $host;
            proxy_set_header   X-Real-IP        $remote_addr;
            proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
        }
}


The essence of the question : is it possible to somehow make nginx not pull the stream via ssh from vlc every time?

For tests, ran "ab" to test:
ab -n 100 -c 100 -g test_data_1.txt -t 60 http://streaming-server:8083/stream.flv

Judging by the “nethogs” logs, the traffic increases not 1:1, but for some reason 1:2 (that is, if nginx gives 3Mbps, then the traffic via ssh is 1.5Mbps), also plink.exe (a tunnel is raised through it) when a new connection to reports to the web server:
Received remote port 8082 open request from 127.0.0.1:54887
Attempting to forward remote port to 127.0.0.1:8082
Forwarded port opened successfully


Solution:
Nothing better and simpler than the usual retiming through vlc could not be found. To get rid of compatibility problems, I downloaded version 2.0.5 x32 for Windows, installed a daily build from ppa for Ubuntu .
The relay command itself is very simple:
cvlc http://localhost:8082/ --sout '#http{mux=flv,dst=:8083/}'

Accordingly, the video should be sent to this address: server_public_name : 8083/

Answer the question

In order to leave comments, you need to log in

8 answer(s)
K
KEKSOV, 2012-12-05
@KEKSOV

The question is not entirely clear - what should nginx do when accessing the proxied address?
If we are talking about keepalive, then you can try adding proxy_connect_timeout 600;
Another small hint about the tunnel. Unfortunately, plink does not have this option , but ssh has the ability to select the stream encryption algorithm. The fastest is with arcfour.
ssh can be found in Cygwin

K
KEKSOV, 2012-12-05
@KEKSOV

Yes, proxy_connect_timeout has nothing to do with it.
I'll still clarify the picture:
1. There is a "secret" server with VLC that distributes the video stream. Apparently, this is a stream from a surveillance camera.
2. There is an nginx server, which can be visited by several people at the same time and everyone needs to distribute the current video stream from the camera.
3. At the same time, I want nginx not to contact VLC for each new visitor, but to “multiply” for all viewers what it receives from the video server.
If the situation is as I described, then you must either try to do something with nginx caching (I really have little idea how nginx will cache the video stream), or look towards this module . Here is the linkto the installation instructions.
And Adobe also has an interesting free product Flash Media Live Encoder , but that's a different story.

S
Serafim, 2012-12-05
@Serafim

In my face a typical XY-problem. I will assume that the initial task is to relay the video stream, I will also assume that the end user is a client with a flash player (or html5). If my two assumptions are correct, then you need flussonic (erlyvideo.ru).

K
KEKSOV, 2012-12-05
@KEKSOV

VLC can transfer video from the camera via RTMP
$ vlc v4l2:// --v4l2-fps=25 --sout '#transcode{vcodec=h264,vb=300,fps=25,scale=1,acodec=mp4a,ab=64,channels=2}:std{access=rtmp,mux=ffmpeg{mux=flv},dst=rtmp://rtmp.server.com:1935/path/to/stream}'
Found here

K
KEKSOV, 2012-12-05
@KEKSOV

Here, it seems that this configuration solves this problem. There, of course, without a glass, you can’t figure it out ...
By the way, if we are talking about browsers, then this player can play rtmp streams (information at the very bottom of the page). I have known him for a long time, but I did not immediately remember him ...

K
KEKSOV, 2012-12-05
@KEKSOV

Sorry, didn't notice the comment about flowplayer...

D
Daniel Newman, 2012-12-05
@danielnewman

maybe I don't understand, but maybe this echo increases 1 to 2?

M
mgk, 2013-02-21
@mgk

or wowza media server

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question