New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dynamically Enabling/Disabling Audio Track Download Based on User Interaction in Shaka Player #6587
Comments
Not currently. It is possible in the MediaSource API, but Shaka Player was not designed for this. I would also anticipate that some devices (smart TVs, I'm looking at you) might not support removing and adding SourceBuffers dynamically. To make this happen, I would guess we would need:
However, I would ask you to consider the encoding ladder for your content and the resolutions/bitrates used by your users who are muting. Are people watching 1080p video at 2Mbps with an unused audio stream consuming only 128kbps? Is it worth it to re-engineer the player to save 5.88% bandwidth? (128 / (2048 + 128)) If it's worth it for you, we would welcome your designs and PRs, and we would be happy to guide you and review your work. |
Thank you for your reply. My use case is more of a social media app featuring a vertical video feed. Our user studies indicate that most viewers prefer watching videos with subtitles in mute state while multitasking, such as during commutes or at work, and only enable sound for particularly interesting content. These users are also conscious of their data usage. Furthermore, minimizing API calls is crucial. For CMAF demuxed audio, preventing audio initialization and segment calls can reduce the time to the first frame. For Android users, I've implemented a solution using ExoPlayer where I disable audio during player initialization by overriding the track selection implementation. If a user decides to enable audio later, I reload the manifest with an overridden 'TIME-OFFSET' field set to 'PRECISE' = true, ensuring they return to the precise moment post-reload. I am able to handle UI transitions smoothly since I am using a surface view for rendering player frames that retain the previous frame. I'm curious if there's a way to adapt this approach to Shaka Player for web users, allowing similar functionality and user experience. |
Sure. You can modify MediaSourceEngine (and StreamingEngine, which calls into MediaSourceEngine) to use web API methods like addSourceBuffer and removeSourceBuffer to dynamically add and remove audio. I see no reason it shouldn't be technically feasible. But we don't have that in our design today. You'd have to make some design changes. We would be happy to have your contributions! The closest you have today is something like:
It's not going to be incredibly smooth. addSourceBuffer/removeSourceBuffer should be much smoother. |
The suggested approach is working fine but is not incredibly smooth, as you suggested. If you can point me to the areas of changes in the player, I can give it a try with the addSourceBuffer/removeSourceBuffer approach. |
Maybe the preload API can help here? (see: https://shaka-player-demo.appspot.com/docs/api/tutorial-preload.html) |
I've tried a solution using the precache API to handle audio tracks based on mute state `
` Do you have any suggestions or see any potential issues with this approach? Is there anything that can be improved? |
Question :
I am working with a demuxed CMAF HLS stream that includes separate .cmfv video segments and .cmfa audio segments. I've noticed that about 40% of users initially watch the stream in a muted state. To conserve bandwidth, I am interested in dynamically controlling the download of the audio track based on user interactions.
Is there a way to enable or disable the audio track download dynamically during runtime in Shaka Player? Specifically, if a user starts with the video muted and later unmutes it, can the player be configured to start downloading the audio track from the next segment onwards at that moment? I know that disabling audio at the player's instance creation through manifest configuration is possible, but I am looking for a method to re-enable it dynamically during runtime. Any workaround approch is also welcome
Shaka Player version : v4.8.3 (latest)
Browser : Google chome (124.0.6367.202)
OS : Mac 14.0
The text was updated successfully, but these errors were encountered: