How does live streaming, using any protocol/codec, work from end-to-end?
I have been searching google, youtube, FFMPEG documentation, OBS source code, stack overflow, but still cannot understand how live video streaming works, from videos. So I am trying to capture desktop screenshots and convert that to a live video stream that is H.264 encoded.
What I know how to do:
- Capture screenshot images using Graphics.CopyFromScreen with C# on some loop
- Encode the bits and save images as JPEG files
- Send JPEG image in base64 one-at-a-time and write it on a named pipe server
- Read image buffer from named pipe on a nodejs server
Send base64 jpeg image over socket to client to display on a web page, each frame
What I want to be able to do:
- Encode, I assume chunks, images into some H.264 format for live streaming with one of the protocols (RTMP, RTSP, HLS, DASH)
- Push the encoded video chunks onto a server (such as an RTMP server), continuously (I assume ever 1-2 seconds?)
- Access server from a client to stream and display live video
I've tried using FFMPEG to continuously send .mp4 files onto an RTMP server but this doesn't seem to work as it closes the connection after each video. I have also looked into using ffmpeg concat lists but this just combines videos, it can't append videos read by a live stream to my understanding and probably wasn't made for that.
So my best lead is from this stackoverflow answer which suggests:
- Encode in FLV container, set duration to be arbitrarily long (according to the answer, youtube used this method)
- Encode the stream into RTMP, using ffmpeg or other opensource rtmp muxers
- Convert stream into HLS
How is this encoding and converting done? Can this all be done with ffmpeg commands?