A fragmented MP4 contains a series of segments which can be requested individually if your server supports byte-range requests.
fMP4格式的文件中,包含多個segments,這些segment可以被單獨請求(如果服務器支持按字節進行讀取的請求的話)。
Boxes aka Atoms
All MP4 files use an object oriented format that contains boxes aka atoms.
You can view a representation of the boxes in your MP4 using an online tool such as MP4 Parser or if you're using Windows, MP4 Explorer. Let's compare a normal MP4 with one that is fragmented:
Non-Fragmented MP4
This screenshot (from MP4 Parser) shows an MP4 that hasn't been fragmented and quite simply has one massive
mdat
(Movie Data) box.
Non-Fragmented MP4
If we were building a video player that supports adaptive bitrate, we might need to know the byte position of the 10 sec mark in a 0.5Mbps and a 1Mbps file in order to switch the video source between the two files at that moment. Determining this exact byte position within one massivemdat
in each respective file is not trivial.
Non-Fragmented MP4包含一個特別大的mdat
(Movie Data) box。
Fragmented MP4
This screenshot shows a fragmented MP4 which has been segmented using MP4Box with the
onDemand
profile.
fragmented MP4基于MP4Box的點播profile進行切割。
You'll notice the
sidx
and series ofmoof
+mdat
boxes.
Thesidx
is the Segment Index and stores meta data of the precise byte range locations of themoof
+mdat
segments.
包含一個sidx和多個moof
+mdat
。
sidx
是segment的索引,并且存儲了moof
+mdat
segments的精確字節范圍。
Essentially, you can independently load the
sidx
(its byte-range will be defined in the accompanying.mpd
Media Presentation Descriptor file) and then choose which segments you'd like to subsequently(隨后) load and add to the MSE SourceBuffer.
開發者可以首先獨立加載sidx
(它的字節范圍可以在一起的.mpd中定義)。
然后確定加載那個segment,并添加到MSE。
Importantly, each segment is created at a regular interval of your choosing (ie. every 5 seconds), so the segments can have temporal(時間的) alignment across files of different bitrates, making it easy to adapt the bitrate during playback.
每個segment按照指定的時長進行創建(比如5秒),所以segments可以在不同比特率的文件之間進行時間對齊,這樣的話,碼率自適應就變得很容易。