jellyfin / jellyfin-androidtv

Android TV Client for Jellyfin
https://jellyfin.org
GNU General Public License v2.0
2.68k stars 457 forks source link

Support dynamically calculating new bitrate at different speed #1569

Open DavidFair opened 2 years ago

DavidFair commented 2 years ago

Describe the feature you'd like

Currently we call setMaxBitrate in PlaybackController based on the assumption all videos play at 1x speed. When a user is playing say 1.25 and the streaming limit is 90% of upload this causes hitching. Equally at lower playback speeds we can transcode at a higher bitrate as the video rate (and relative mbps) is higher.

I'm happy to work on this (though I can't assign myself) and I can see 90% of the implementation way forward. My plan would be:

However I'm a bit stumped because of the legacy code in PlaybackController. The video track selection is selected in playInternal, so what is the correct way to select a different video track? Since we don't have bitrate selection in this project there's no existing code to follow along with so some guidance would be great on this :slightly_smiling_face:

mueslimak3r commented 2 years ago

This could definitely be useful though I think it should have a toggle in the preferences.

For mid-playback bitrate switching you could reference this PR: https://github.com/jellyfin/jellyfin-androidtv/pull/1406

It's stalled due to some mysterious issues with toggling audio output modes but afaik the bitrate adjustment part works fine.

DavidFair commented 2 years ago

This could definitely be useful though I think it should have a toggle in the preferences.

So thinking about this, if there was a toggle it would make sense to toggle using the bitrate limit off for all playback (rather than at a different speed), since you're either limited by it or don't really care from it.

There's some concerns with this though, as it effectively "allows" a user to bypass a network cap places by an administrator. If I want to slice a 40mbps connection into 10mbps slices having an option where a user can either turn it off (for the full 40, or 20 at 2x speed) will impact other users. Obviously someone whose determined can always find a way to bypass the limit, I'm concerned about that one family member who "finds a trick in the preferences menu" to get more bandwidth and the headache it causes for other people.

What are your thoughts on this?

mueslimak3r commented 2 years ago

The reason why I think it should be a toggle between fixed (user selected) max bitrate and auto adjusted (based on playback speed) is that there are a lot of users who either prefer to avoid transcoding whenever possible, or who will do everything they can to disable transcoding even at the expense of functionality.

Another factor is that plenty of users will either be streaming over LAN or even remotely with a fast connection, and they may prefer an unmodified stream and have bandwidth to support it.

As far as bypassing a network cap goes, my assumption about the settings that limit the bitrates in the jellyfin dashboard is that they are more a best-effort QoS type thing than a truly effective way to meter your server's limited bandwidth. Those caps are still only effective if a use is allowed to transcode and the client supports transcoding. A user can still play via a 3rd party client like Infuse or MrMC, which only support direct play, and none of the bandwidth settings will apply to them.

Also, afaik the app preference for bitrate used in this app is completely disconnected from any server-side preferences