Long story short: Why HLS can't just play normal MP4 files together one after one? Why need to segment media file into .ts segments?
Details:
We've segmented MP4 file into mini MP4 segments (not TS), each one about 30 seconds for testing. It never plays in any HLS player, just loading all segment files then nothing happens.
Example MP4 segment Info:
Format : MPEG-4
Format profile : Base Media
Codec ID : isom
File size : 1.44 MiB
Duration : 32s 950ms
Overall bit rate : 366 Kbps
Writing application : Lavf56.25.101
Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : [email protected]
Format settings, CABAC : Yes
Format settings, ReFrames : 6 frames
Codec ID : avc1
Codec ID/Info : Advanced Video Coding
Duration : 32s 950ms
Bit rate : 230 Kbps
Width : 426 pixels
Height : 240 pixels
Display aspect ratio : 16:9
Original display aspect rat : 16:9
Frame rate mode : Constant
Frame rate : 23.976 fps
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.094
Stream size : 925 KiB (63%)
Writing library : x264 core 142 r2495 6a301b6
Audio
ID : 2
Format : AAC
Format/Info : Advanced Audio Codec
Format profile : LC
Codec ID : 40
Duration : 32s 896ms
Bit rate mode : Constant
Bit rate : 129 Kbps
Channel(s) : 2 channels
Channel(s)_Original : 6 channels
Channel positions : Front: L C R, Side: L R, LFE
Sampling rate : 48.0 KHz
Compression mode : Lossy
Stream size : 517 KiB (35%)
The Master M3U8:
#EXTM3U
#EXT-X-VERSION:7
#EXT-X-INDEPENDENT-SEGMENTS
#EXT-X-STREAM-INF:RESOLUTION=426x240,BANDWIDTH=370000,CODECS="avc1.640015,mp4a.40.2"
240p.m3u8
#EXT-X-STREAM-INF:RESOLUTION=640x360,BANDWIDTH=580000,CODECS="avc1.640015,mp4a.40.2"
360p.m3u8
#EXT-X-STREAM-INF:RESOLUTION=896x504,BANDWIDTH=900000,CODECS="avc1.640015,mp4a.40.2"
480p.m3u8
#EXT-X-STREAM-INF:RESOLUTION=1280x720,BANDWIDTH=1500000,CODECS="avc1.640015,mp4a.40.2"
720p.m3u8
240p.m3u8
#EXTM3U
#EXT-X-VERSION:7
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-PLAYLIST-TYPE:VOD
#EXT-X-TARGETDURATION:34
#EXTINF:33.033033,
240p000.mp4
#EXTINF:33.533534,
240p001.mp4
#EXTINF:24.941608,
240p002.mp4
#EXTINF:28.611945,
240p003.mp4
#EXT-X-ENDLIST
When tested with HLS.js, gives this error:
Parsing Error:no demux matching with content found,cannot recover, last media error recovery failed ...
Bitmovin Player: loads all segments of all variants and never plays any of them. just stop.
Tested on Chrome & Firefox On Windows, Safari on Mac, Android and iPad Browsers. Never works on any of them. Are we doing anything wrong?!
While transport stream segments are self-initializing, this is usually/often not the case for fMP4 segments. Therefore, you will need to add the initialization segment to the manifest file, which is needed to initialize the decoder. This can be done using the #EXT-X-MAP:URI tag as shown in the image of this blog post and in the example below:
#EXTM3U
#EXT-X-TARGETDURATION:4
#EXT-X-VERSION:7
#EXT-X-MEDIA-SEQUENCE:1
#EXT-X-PLAYLIST-TYPE:VOD
#EXT-X-INDEPENDENT-SEGMENTS
#EXT-X-MAP:URI="init.mp4"
#EXTINF:4.0
segment_0.m4s
#EXTINF:4.0
segment_1.m4s
...
#EXT-X-ENDLIST
I'm not sure about HLS.js, but this should work at least for the Bitmovin Player. If not I'd recommend to use Bitmovin's support.
Apple also provides a test page with fMP4 HLS (requires native HLS support in the browser, such in Safari), and Bitmovin has a demo page with fMP4 HLS avialable.