Iqiyi, Tencent Video, Youku, Bilibili… We often watch TV series and movies on these websites. Many students have one or more members in order to catch up with TV series before the first time or do not like to see advertisements

You say these websites, we rush so many members, why not profit…

Now H5 has a video tag, and you can directly fill in the video address to watch it. And you can play it side by side.

Yes, but this type of streaming is Progressive Download, a form of “pseudo-streaming” that downloads movies locally and exposes the original location of the video, so who needs a membership?

So, today, let’s take a look at how these sites present their videos to us.

Protocol support

RTMP & HTTP_FLV

FLV (Flash Video) is another Video format developed by Adobe. It is a storage container format for streaming media data over the network. Why put http_FLV and RTMP together? Because the two protocols actually transfer the same data. The data is FLV files.

RTMP is a Real Time Messaging Protocol. Adobe’s proprietary protocol for transferring audio and video data between Flash players and servers. A plaintext protocol that works over TCP and uses port 1935 by default. The basic data unit in the protocol is called a Message, which is divided into smaller Chunk units during transmission. Finally, the segmented message block is transmitted through TCP protocol, and the receiving end decomparts the received message block to restore the streaming media data. RTMP’s low latency makes it suitable for live streaming. However, RTMP is based on TCP transport and is not a public port. Apple has always wanted to kill Flash, so none of their devices support RTMP.

Http-flv is also introduced by Adobe, which selects corresponding programs to process corresponding Content according to the content-Type in HTTP, so that streaming media can be transmitted over HTTP. Compared with RTMP, HTTP-FLV can penetrate firewalls better. It is based on HTTP/80 and effectively avoids being intercepted by firewalls. In addition, it can flexibly schedule and load balance through HTTP 302 jump, supports HTTPS encrypted transmission, and is compatible with Android and iOS mobile terminals.

HLS

HTTP Live Streaming (HLS) is a media Streaming protocol based on HTTP implemented by Apple. Apple’s full series of product support. Since HLS was proposed by Apple, all Apple products including iPhone, iPad and Safari can support playing HLS without any plug-in. Android has added support for HLS because of Apple’s position on mobile. Most PC browsers don’t support native HLS, but one of them is Edge.

The basic principle of HLS is to divide video files into many small TS files, and establish an INDEX file of M3U8 to maintain the index of the most TS fragments. When playing a video, it retrieves the TS video file fragment from the M3U8 index file to play. Compared with RTMP, the biggest difference of HLS is that the live broadcast client does not obtain a complete data stream, but a continuous, short-duration media file. The client continuously downloads and plays these small files. HLS can smoothly switch bit rate to adapt to different bandwidth conditions of playback.

However, HLS has a large delay when it is used as a live broadcast, so HLS is more suitable for on-demand services. Iqiyi, Tencent and Youku all use HLS for their new videos.

MPEG DASH

Apple introduced HLS, but it was only supported by Apple devices, and Adobe’s agreement was not supported by Apple, which made it very difficult for developers to develop. So many companies (including Apple) came together to create DASH, a new international standard.

Similar to Apple’s HTTP Live Streaming (HLS) technology, MPEG-Dash streams content into small SEQUENCES of HTTP-based file segments. Each file segment can be encoded at different bit rates to meet the network requirements of different clients. For example, DASH clients can automatically select the best bit-rate file segment to download based on current network conditions and play it back without causing a pause or re-buffering. In this way, DASH clients can seamlessly adapt to changing network conditions and provide high-quality playback with minimal pauses or buffering. DASH also features similar features to HLS in that it has a high latency for live streaming. Bilibili, YouTube, Netflix and Hulu all use DASH

application

Each protocol can only support some devices, so media development can only develop multiple protocols? Apparently not, thanks to the browser’s new API, MSE (Media Source Extensions API)

The Media Source Extension API (MSE) provides the capability to implement plug-in – free web-based streaming media. With MSE, media streams can be created in JavaScript and can be played using

Therefore, in the era of H5, most live video websites still use the form of FLV in the field to ensure low delay, and play in H5 through FLV.js. In the field of on-demand, major websites can choose between DASH and HLS to implement H5 playback through Dash.js or hlS.js. Although DASH is an international standard, HLS came out earlier and dominated the industry.

By now, videos should be able to play under any protocol, but for video sites, there is still a major problem to solve — anti-download. After all, the website spent a lot of money to buy the copyright, can not be easily downloaded to take away. Slices of DASH and HLS can make downloading difficult, but it’s not too difficult for technicians to download the whole thing and reverse it. We all know there are no secrets on the front end, so the only way to solve this problem is to start with the content, encrypting the video.

For example, HLS supports AES-128 encryption and uses FFmpeg to slice and encrypt video files. You can see the # ext-X-key in the generated M3U8 file

In this way, the video is encrypted, but there is a new problem. When requesting the secret key, the secret key will be exposed, and the video can be decrypted by getting the secret key. This is also the problem of symmetric encryption. The secret key is exposed during transmission, but the decryption efficiency is high during video playback, so asymmetric encryption cannot be used.

So the core technology of a video site is how to hide the secret key. I’m not going to delve too far into this, but here’s an idea: provide a private protocol on the URI, then intercept the request, get the address content, perform various transformations on it, and finally get the secret key.

The processing method of each website is not the same, but there is a point to be sure that no matter how deep the secret key is hidden, there will always be a way to get it, the so-called anti-download is not 100% safe, after all, there is no physical plug-in – recording screen. All you can do is raise the bar so that most people can’t easily take it away.

So, you know why so many shows failed to finish this year? Give it a thumbs up first!