且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

HTML5视频如何处理最后带有moov原子的视频

更新时间:2023-09-22 09:45:04

亚历山大法尔卡斯(Alexander Farkas)8/2的评论是一个完美的答案,如果简洁的话.范围请求(也称为字节服务")允许客户端请求文件的任何部分.

The comment by Alexander Farkas from 8/2 is a perfect, if succinct, answer. Range requests (also known as "Byte Serving") allow the client to request (any) part of the file.

客户端发出(至少)三个具有HTTP 206响应的GET请求(只要服务器能够处理范围请求):一个用于文件头(内容长度很重要,以及接受范围:字节" ").然后,客户端请求文件的结尾,通常少于内容的最后一个MB(这似乎因浏览器而异);一旦客户端从文件末尾获得了moov原子,它就会请求其余的内容.当您进行搜索时,元数据使客户端可以知道如何将时间映射到字节范围,并发出对部分内容的新请求.

The client makes (at least) three GET requests with HTTP 206 responses (provided the server is capable of handling range requests): one for the file headers (Content-Length is what matters, along with "Accept-Ranges: bytes"). Then the client requests the end of the file, usually less than the last MB of content (this seems to vary by browser); once the client has the moov atom from the end of the file, it requests the rest of the content. When you seek, the metadata allows the client to know how to map time to byte range, and issues a new request for partial content.

有关实际情况的合理记录,请参见示例HTTP范围请求会话

A reasonable transcript of what this looks like in practice is at Sample http range request session