Node.js Live Stream Web Server: Problems with the <video> Tag

I use Node.js as a streaming server for real-time streaming video that is sent by FFMPEG (executed from another application, the stream is executed via HTTP) and obtained using webapp, which uses a tag.

This is what I do: FFMPEG passes the received frames with the following command:

ffmpeg -r 30 -f rawvideo -pix_fmt bgra -s 640x480 -i \\.\pipe\STREAM_PIPE -r 60 -f segment -s 240x160 -codec:v libvpx -f webm http://my.domain.com/video_stream.webm 

(the stream comes from an application that uses Kinect as a source and communicates with FFMPEG through the channel, sending one frame after another)

When the webapp connects, it immediately receives a response from the server:

 HTTP/1.1 200 OK X-Powered-By: Express content-type: video/webm cache-control: private connection: close Date: Fri, 06 Dec 2013 14:36:31 GMT 

and the Webm header (previously stored on the server with the same resolution and frame rate of the original stream and tested as running on VLC) is immediately added. Then webapp begins to receive data transmitted by FFMPEG. Here is a screenshot of the Mkvinfo GUI showing header fields:

Header screenshot

However, even if the "Network" tab of the Chrome console shows that there is an actual data stream (this means that streaming is not completely garbage, otherwise the connection will be deleted), the player does not display anything. We tried to manually add our title to the downloaded video received by webapp, and VLC plays it just fine, but this does not happen with the tag.

What can cause this problem? Are we missing something in the encoding on the FFMPEG side or are we storing the wrong values ​​in the header (or are they not enough)?

PS: I cannot rely on an extern stream server.

PPS: We tried the following experiments:

  • Substituting the video title to the one stored on the server, plays the video on both vlc and video tags
  • if we discard a video that is already running (without a title), and we add the title of the video stored on the server or even its original title, the video is played in VLC, but not on the tag (we carefully add the title before starting the cluster).
+6
source share
1 answer

So many variables are added to this problem when you consider using technology outside (and not integrated) node to stream video. This can lead to problems with the bootloader or proxy server you are using, or it may be that you have 2 applications on the same port.

Can you do streaming only in node? Or could you just pass ffmpeg to the file system and stream using node.fs.readStream ()? This will allow you to reuse the same web server instead of creating a completely new server in one window. And if you just transfer this content from point to point, then you need to buffer the data passing through and forward the buffer as a stream through node.

The reason technology integrates, wraps and spreads into other structures is explained by uniformity. Reading his question, although well detailed, he still leaves a lot to the side. This may lead to the question of how ffmpeg converts and serves http content, and how your loadbalancer / proxy handles this. Does node have anything to do with this? Is there a replacement for ffmpeg so you can standardize the node structure? Is node correct for these applications?

+1
source

Source: https://habr.com/ru/post/959483/


All Articles