Feature: Support MultiTrack Audio
Support MultiTrack Audio.
- selectAudioTrack in MSEPlayer
- Support FLV (eFLV v2) and MPEG-TS
- Live Seamless Codec switching
Thank you very much for your great work!
There's a background that, the feature of switching between multiple audio tracks has also been necessary in KonomiTV. It is an important feature provided in KonomiTV until now, but it has still not been merged or implemented here due to the difficulty of how to design the interface of audio switching. A careful API design becomes necessary which will be provided to the user eventually. https://github.com/xqq/mpegts.js/pull/21 https://github.com/tsukumijima/mpegts.js/commit/a0fd4c62a1d64ed336a47c1274bbad32652e40e2
It could be better to provide a consistent interface in MSEPlayer for the user to switch between multiple audio tracks, which should work both for eFLV and MPEG-TS of course.
It should also be better to provide an interface to let the user know or be able to query how much the audio tracks exist inside the input stream, also with some extra information like the codec/profile/samplingRate/bitrate(if known) of each audio track, etc. Then the user could switch to a specific audio track by calling some switching method by providing a reliable audio track index.
BTW, in tsukumijima's fork, the audio track switching is seamless and nearly real-time, which can switch very fast without interrupting the playback, and it didn't do the unload and then load again which is unnecessary and will cause a bad experience.
I believe there could be some cases of switching audio tracks between different audio codecs. This is still impossible in the current version of mpegts.js.
The latest specification (and most implementations) of Media Source Extensions has support SourceBuffer.changeType(). In order to support it, firstly I have to refactor the MSEController.
@xqq Thank you for your response and feedback! Seamless codec switching more interesting, I wish to support it. (but, I'll leave it to you if you want to implement)
And, FLV for VOD, sequence header does not send regularly, only first time, I think. So, I would like to implement initialization segment cache for each sequence header.
If FLV(VOD) and reached endOfStream, such case reconnect http stream and fetch data. In worst case (use default loader), reloading and dynamic codec switching are same behavior.
I think that needs different implementation for live or not.
@xqq MPEG-TS multitrack support and ChangeType for MSE are implemented, please see it!