3

With VLC 2.2.1 I create an HTTP stream of my webcam hosted by a computer named server.

On another computer, client, if I open vlc, and open the network stream http://server:8080 I can see the webcam video perfectly.

A wireshark capture of the HTTP stream look like the following :

GET / HTTP/1.1
Host: server:8080
User-Agent: VLC/2.2.0-rc2 LibVLC/2.2.0-rc2
Range: bytes=0-
Connection: close
Icy-MetaData: 1

HTTP/1.0 200 OK
Content-type: application/octet-stream
Cache-Control: no-cache

FLV.......................
[email protected].@~.......
videodatarate.@[email protected][email protected]..
Lavf56.1.0..filesize....
etc...

On the client computer, I have an API running under NodeJS v5 & Express v3 and I'd like to have an url like : http://client/video that act as a proxy to http://server:8080 so the users can only see one endpoint.

I saw few npm module claiming to act as "proxy" but due to the special nature of the content (live video stream) I'm not sure of what I should do.

1 Answer 1

2
var express = require('express')
var fetch = require('node-fetch')

var app = express()

app.get('/video', (req, res) => {
  fetch('http://server:8080')
    .then(r => r.body)
    .then(s => {
      s.pipe(res)
    })
    .catch(e => {
      res.status(500).send('Error.')
    })
})

app.listen(80)

to open up port 80, you'll need to be root, so run with sudo

Sign up to request clarification or add additional context in comments.

2 Comments

will this affect the bandwidth of the express server instance?
yep, it's just streaming one connection to another. Try a redirect, as an alternative, if you don't want to use up your express app's bandwidth.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.