videojs / video.js

Video.js - open source HTML5 video player
https://videojs.com
Other
38.02k stars 7.45k forks source link

How to filter only audio that its codec is supported #8885

Open vanminhquangtri opened 2 weeks ago

vanminhquangtri commented 2 weeks ago

First of all, videojs is really nice, thank you for your all effort to offer a perfect player for community. We use videojs for years and have many positive comment from our clients.

At this moment, we are using multi codec for audio, not only AAC, we also use AC3, E-AC3. Some of these codecs is not widely supported by browsers. For example Chrome window not support AC3, E-AC3. But unfortunately, function player player.audioTracks() is still return these audio. Then when user select these codecs, player is paused.

You can check a demo here on Chrome on Window: https://codesandbox.io/p/sandbox/videojs-player-3cvkd4?file=%2Findex.html%3A16%2C83-16%2C105

So my question is, 1/ In videojs, is there any function/config to only get the supported audio codecs when we call player.audioTracks()? 2/ Or how to detect the codec of audio from the list audio of player.audioTracks()? We will ourself check if codecs is support we will show.

Thank you.

adrums86 commented 4 days ago

Hi @vanminhquangtri , is there an error thrown when trying to change to an unsupported codec? VHS should be checking the playlists on initialization for unsupported codecs via excludeUnsupportedVariants_ on initialization https://github.com/videojs/http-streaming/blob/8456cb3c1c8af207156c0330a9cc2050592e8880/src/playlist-controller.js#L2062. If these codecs are not supported by MSE (need to be transmuxed), they may not be supported by mux.js yet or there could be a bug.

Regardless, if you want to manually filter the available player.audioTracks you can use the player.audioTracks().removeTrack(trackToRemove) function to remove available audio tracks.

vanminhquangtri commented 4 days ago

Hello @adrums86 , thanks for your response. Player not throw any error when switch to un-supported audio codec. It just loading. And the video tag is paused.

This is my demo and screen recorder the issue https://codesandbox.io/p/sandbox/videojs-player-3cvkd4?file=%2Findex.html%3A55%2C15

https://github.com/user-attachments/assets/147383b2-c6c7-4b13-a0f0-69cb16f7db9c