A fragmented MP4 contains a series of segments which can be requested individually if your server supports byte-range requests.
fMP4格式的文件中,包含多個(gè)segments,這些segment可以被單獨(dú)請(qǐng)求(如果服務(wù)器支持按字節(jié)進(jìn)行讀取的請(qǐng)求的話)。
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包含一個(gè)特別大的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的點(diǎn)播profile進(jìn)行切割。
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.
包含一個(gè)sidx和多個(gè)moof
+mdat
。
sidx
是segment的索引,并且存儲(chǔ)了moof
+mdat
segments的精確字節(jié)范圍。
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.
開(kāi)發(fā)者可以首先獨(dú)立加載sidx
(它的字節(jié)范圍可以在一起的.mpd中定義)。
然后確定加載那個(gè)segment,并添加到MSE。
Importantly, each segment is created at a regular interval of your choosing (ie. every 5 seconds), so the segments can have temporal(時(shí)間的) alignment across files of different bitrates, making it easy to adapt the bitrate during playback.
每個(gè)segment按照指定的時(shí)長(zhǎng)進(jìn)行創(chuàng)建(比如5秒),所以segments可以在不同比特率的文件之間進(jìn)行時(shí)間對(duì)齊,這樣的話,碼率自適應(yīng)就變得很容易。