video-dev / hls.js

HLS.js is a JavaScript library that plays HLS in browsers with support for MSE.
https://hlsjs.video-dev.org/demo
Other
14.81k stars 2.57k forks source link

does not support MPEGTS and muxed fMP4 segments in the same HLS stream #1510

Closed KingKebab closed 6 years ago

KingKebab commented 6 years ago

Hello,

Tested some HLS video streams with adaptive bitrates mixing MPEGTS and fMP4 video tracks and I found hls.js v0.8.9 can't switch automatically from TS segments to M4S segments when quality control is set on "Auto".

I get this parsing error message : TS packet did not start with 0x47 But forcing the video quality manually to an upper bitrate/resolution works properly.

MPEGTS is required to keep old iOS device compatibilty and fMP4 is essential for HEVC.

Here is a interesting sample stream I can provide : http://sample.vodobox.com/caminandes_1_4k/caminandes_1_4k.m3u8

It contains 8 video qualities : . AVC Baseline / 256x144 / 256kbps / MPEGTS . AVC Baseline / 426x240 / 498kbps / MPEGTS . AVC Baseline / 640x360 / 1277kbps / MPEGTS . AVC Baseline / 854x480 / 1971 kbps / MPEGTS . AVC High / 1280x720 / 3152 kbps / fMP4 . HEVC Main / 1280x720 / 1899 kbps / fMP4 . HEVC Main / 1920x1080 / 4055 kbps / fMP4 . HEVC Main / 3840x2160 / 7483 kbps / fMP4

This HLS stream works properly with Apple official video player in iOS 11 and macOS X High Sierra. It swicth between TS and M4S tracks without freeze.

Hope this short sample will help you. Kind regards.

mangui commented 6 years ago

Hi @KingKebab , well spotted. i added some logic to handle demuxer switch on track switch. but it is not enough to cover your case :

when using TS demuxer, we create 2 sourcebuffers, one for audio, one for video. when using MP4 demuxer, we use one sourcebuffer per demuxer. in your case audio and video are interleaved into the same fragment. mp4 demuxer does not re-split audio and video into separate buffers. (mp4demuxer is able to parse your chunk, it detects both audio and video in the same chunk and signal them, then stream-controller tries to append this buffer into a shared audiovideo sourcebuffer which does not exist in your case as playback has been started with a TS demuxer, which had signalled 2 elementary stream, audio and video, leading to the creation of the 2 separate sourcebuffers)

supporting this case is not infeasible, but it would require splitting / demuxing the fmp4 chunk into 2 separate chunks to accomodate with the existing 2 sourcebuffers. not trivial ..

if you use late audio binding / alternate audio track, this should work seamlessly now.

ghost commented 6 years ago

Is there any example or document that shows how we can run a fragmented MP4 with HLS JS? I have a fragmented MP4 file with different Audio Tracks. I don't know how to play that with HLS JS.

stale[bot] commented 6 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

vincentbernat commented 6 years ago

This is said to be fixed in 0.9. However, when testing with 0.10 and the provided m3u8, the quality tries often to switch to level 4 but has to fallback to level 3 before playing the fragment. The log doesn't say why it falls back to level 3.

skyzyx commented 6 years ago

Would still love to see some concrete information about whether or not there is support for this.

johnBartos commented 6 years ago

@skyzyx There hasn't been further work on this request so it's still as mangui said above

zalishchuk commented 1 year ago

Any updates on this issue? I still experiencing some problems with having H.265 (fmp4) and H.264 (ts) segments in the same stream manifest, it's playing fine until you manually switch the level to the HEVC and then the player just freezes without throwing any kind of error or information.

Or can someone please provide some explanation on how to make things work?