First, create file stdin-to-http.js
:
require('http')
.createServer(function (req, res) {
res.writeHead(200, {
'Content-Type': process.argv[2]
});
if (req.method === 'HEAD') {
return res.end();
}
process.stdin.pipe(res);
})
.listen(1337);
Then:
your-mpeg-video-source | node stdin-to-http.js video/mpeg
. your-mpeg-video-source
can be for example rtmpdump -r rtmp://tv.example.org/live/stream1?token=abcdef | ffmpeg -re -i pipe:0 -bufsize 4096k -maxrate 4096k -vcodec h264 -preset fast -b:v 500k -acodec aac -b:a 128k -strict -2 -f mpegts -
or ffmpeg -f video4linux2 -i /dev/video0 -pix_fmt yuv420p -bufsize 4096k -maxrate 4096k -vcodec h264 -preset fast -b:v 2000k -f mpegts -
or curl https://cdn.example.org/my-video-file | ffmpeg -i pipe:0 -bufsize 4096k -maxrate 4096k -vcodec h264 -preset fast -b:v 2000k -acodec aac -b:a 128k -strict -2 -f mpegts -
.http://your-computer-ip-in-lan:1337/
(e.g. http://192.168.1.42:1337
) and click on media renderer to play!P.S. You can also start playing the stream using upnp-mediarenderer-client.