• Login
  • Register
  • Login Register
    Login
    Username/Email:
    Password:
    Or login with a social network below
  • Forum
  • Website
  • GitHub
  • Status
  • Translation
  • Features
  • Team
  • Rules
  • Help
  • Feeds
User Links
  • Login
  • Register
  • Login Register
    Login
    Username/Email:
    Password:
    Or login with a social network below

    Useful Links Forum Website GitHub Status Translation Features Team Rules Help Feeds
    Jellyfin Forum Support General Questions Dynamic user bandwidth allocation?

     
    • 0 Vote(s) - 0 Average

    Dynamic user bandwidth allocation?

    Thinking about building some kind of user bandwidth QoS daemon ....
    dakazze
    Offline

    Junior Member

    Posts: 20
    Threads: 6
    Joined: 2024 Oct
    Reputation: 0
    #1
    2025-06-10, 09:11 PM
    Hey guys!

    Sadly it looks like it will take another year until we finally get fiber here and for the time being I am stuck with 50 MBits upload. Since I only have 2-3 users outside of my LAN and not too much concurrent use, limiting their upload to 20 MBits has been working fine but thinking about ways to make the most of what I got I came up with this concept and I would appreciate some input for the jellyfin side of things (API possibilities, etc.):

    So my plan is to build a node or python daemon that basically has 2 main components.

    1. Talk to openWRT:
    Keep asking the openWRT router about the demand for upload bandwidth outside of Jellyfin and if I am super motivated, it might dynamically change SQM settings.

    2. Talk to Jellyfin:
    Keep asking Jellyfin how many users are streaming outside of the LAN and dynamically limits upload bandwidth for each remote user.

    This way a single streaming user can have 100% of the bandwidth as long as there is no other demand for it. When a second remote user starts streaming, both get an equal share of the bandwidth and when there is high priority demand from my office PC I can still ensure that both remote clients still have a good minimum share of the cake to stream their stuff.
    This way the upload bandwidth I have available is always utilized as good as possible and my users get the best possible quality all the time, only getting throttled when actually needed.


    I would really appreciate every bit of input:
    • Does something similar already exist?
    • What do you think about this idea/approach?
    • Is there some kind of dynamic bandwidth allocation already implemented in Jellyfin or only the static limit?
    • Is there anything speaking against this idea?
    • Does the API already support getting the info from Jellyfin (amount of remote users currently streaming) and updating the bandwidth limits for each user?
    • I could build a version that skips the openWRT implementation so it only allocates bandwidth dynamically based on a set value and therefor can be used by everyone. Do you think there is enough demand for a feature like this?
    Thank you very much for reading all of this!
    akepound
    Offline

    Junior Member

    Posts: 1
    Threads: 0
    Joined: 2025 Jun
    Reputation: 0
    Country:United States
    #2
    2025-06-11, 07:27 AM
    Your idea of a daemon that dynamically checks both OpenWRT and Jellyfin states is solid. For Jellyfin, the API does expose session info (/Sessions) which includes whether a user is streaming, their IP (LAN or WAN), bitrate, etc. So tracking remote streaming users in real time is totally doable.
    dakazze
    Offline

    Junior Member

    Posts: 20
    Threads: 6
    Joined: 2024 Oct
    Reputation: 0
    #3
    2025-06-11, 05:30 PM
    Thank you @akepound !

    I just finished studying the API a bit and it looks like everything I need is already in place.
    The only important piece of info I am missing (for now) is what happenes after changing the bandwidth/bitrate limit mid session. Does anyone know if it is applied right away mid-session or if it would take a session restart for the change to take effect?
    If it does not work mid session I would have to figure out a way to make the process as seamless as possible.
    Venson
    Offline

    Moderator, Server Dev, XBox Maintainer

    Posts: 381
    Threads: 7
    Joined: 2023 Jun
    Reputation: 15
    Country:Germany
    #4
    2025-06-12, 08:01 AM
    no a bitrate change mid-session does not change a stream in progress
    typos are finders, keepers.
    Next Jellyfin release 10.11.0 will be Soon™
    Soon™ is an unregistered trademark of Jellyfin International
    dakazze
    Offline

    Junior Member

    Posts: 20
    Threads: 6
    Joined: 2024 Oct
    Reputation: 0
    #5
    2025-06-12, 10:34 PM (This post was last modified: 2025-06-13, 12:02 AM by dakazze. Edited 1 time in total.)
    (2025-06-12, 08:01 AM)Venson Wrote: no a bitrate change mid-session does not change a stream in progress

    Thank you very much for this info! 
    I already built the framework for my little daemon and it is already getting active sessions, checking their IPs, getting and setting the bandwidth for each user.

    Applying the changes mid session proofs harder than expected though, so I would be grateful for any idea that might help.
    For now I am using the playing/stop endpoint to force stop a session which is then automatically resumed but it is a ~3 seconds interruption that is flashing the episode selection for ~1 second which is far from seamless.

    (edit: almost finished with a first fully working version. I already prepared a github repo and will share it once done)
    Efficient_Good_5784
    Offline

    Community Moderator

    Posts: 1,173
    Threads: 3
    Joined: 2023 Jun
    Reputation: 50
    #6
    2025-06-13, 04:23 AM
    Considering that the server stops the current ffmpeg process and creates a new process with the updated settings, maybe making it launch a new ffmpeg process while the old one is still running can solve the issue.

    Then, it would just be a matter of timing the new transcode to align with the old one, switching to the new one, and finally deleting the old process when done.
    dakazze
    Offline

    Junior Member

    Posts: 20
    Threads: 6
    Joined: 2024 Oct
    Reputation: 0
    #7
    2025-06-14, 08:49 PM
    (2025-06-13, 04:23 AM)Efficient_Good_5784 Wrote: Considering that the server stops the current ffmpeg process and creates a new process with the updated settings, maybe making it launch a new ffmpeg process while the old one is still running can solve the issue.

    Then, it would just be a matter of timing the new transcode to align with the old one, switching to the new one, and finally deleting the old process when done.

    Thanks for taking the time to chime in!

    I already tried via ffmpeg but for some reason it did not work out. I think it was because there is only a ffmpeg process when transcoding so updating users in a direct play session would not work.

    With a bit of tuning I might get this working without it being too intrusive:
    - change bandwidth limit
    - get current episode and timestamp
    - stop playback
    - start playback
    - jump to timestamp

    All of this is already working in my current build but it somehow is pretty hard to really allign the timestamp correct. Another unforeseen challenge is getting a good reading of jellyfins outgoing traffic (excluding streams of local users) due to flow offloading but I already have a few ideas on how to get a reliable reading on that.
    « Next Oldest | Next Newest »

    Users browsing this thread: 1 Guest(s)


    • View a Printable Version
    • Subscribe to this thread
    Forum Jump:

    Home · Team · Help · Contact
    © Designed by D&D - Powered by MyBB
    L


    Jellyfin

    The Free Software Media System

    Linear Mode
    Threaded Mode