What is HTML5 streaming
What is HTML5 streaming
Quite often, clients ask if our server is capable of "mp4 streaming in HTML5". In 99% of cases, the questioner does not understand what he is talking about. It’s hard to blame customers for this: due to the confusion with terms, technical complexity and a wide variety of streaming options, it’s very easy to get confused.
In this article mpvplayer we will explain what HTML5 streaming is, which options are good, and why the hell you can’t say “mp4 streaming”.
HTML5 video is when you insert a <video> tag into a web page and give it some kind of src. HTML5 streaming is the same HTML5 video, but when the src is not a ready-made file, but a constantly updated video stream. A YouTube video is an HTML5 video, a Twitch broadcast is an HTML5 stream.
The <video> tag does not care how the video stream is formed and transmitted, and whether the browser can play it. The main thing is that the src contains a link to some video stream. Technically speaking, the specification says nothing about what protocols, transports, and codecs are supported in HTML5 video.
A protocol is how two participants in a video call (almost always a client and a server) communicate to receive data. The client is the one who comes to the server and initiates a communication session. The video stream can flow from the server to the client (then it is normal playback) or from the client to the server (then it is publication). Even when a gigantic cabinet that eats electricity like an apartment building comes to a small IP camera, it will be the server, and this cabinet will be the client.
The protocol usually implies at least a Play command (start playback), but sometimes there are extended options: pause, continue, publish, rewind, etc like shown here mpvplayer.com.
Protocol examples: RTSP, RTMP, HTTP, HLS, IGMP.
A transport, or transport container, or container is how compressed video is packaged into bytes for transmission from one participant to another (using some protocol).
Container examples: MPEG-TS, RTMP, RTP.
Note that RTMP has appeared in both protocols and transports. This is because in the RTMP description there is a specification of both what the parties must send to each other in order for the video to flow (i.e. protocol), and how to package the video (i.e. transport). This is not always the case. For example, in the RTSP protocol, video is packaged in an RTP transport.
Codec is an ambiguous term. Here it means a way to compress raw video. The difference between a codec and a transport is that a codec is about preparing video, while a transport is about transmitting video over a protocol. Video compressed with one codec can be sent using different protocols and different transports. Most video streaming servers don't go deeper than the encoded video and only deal with protocols and transports.
Codec examples: h264, aac, mp3.
Due to the fact that the term is ambiguous, there is confusion with the names. For example, H.264 is a standard for how to pack a stream of huge raw video frames into very few bytes, libx264 is a compression library for this standard, and there is also software for Windows of the same name that can decode h264 and play it on the screen.