• 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 Troubleshooting Limit ffmpeg CPU usage (no Hardware decoding/encoding)

     
    • 0 Vote(s) - 0 Average

    Limit ffmpeg CPU usage (no Hardware decoding/encoding)

    I-G-1-1
    Offline

    Junior Member

    Posts: 21
    Threads: 2
    Joined: 2023 Jun
    Reputation: 0
    #1
    2025-02-11, 12:00 PM (This post was last modified: 2025-02-11, 12:00 PM by I-G-1-1. Edited 1 time in total.)
    Normally I'm using hardware (VAAPI) transcoding but there is a device (iPhone) that always trigger CPU conversion from my h.265 mkv media:

    Code:
    [/color][color=#000000]Stream #0:0 -> #0:0 (hevc (native) -> h264 (h264_vaapi))[/color]
    [color=#000000]Stream #0:1 -> #0:1 (ac3 (native) -> aac (libfdk_aac))[/color][color=#000000]


    I tought that wasn't a problem as is a single user and the CPU is an i5-6300U capable to perform the job. Instead after a while the CPU transcoding completely lock the system and the server become unresponsive and I can't even ssh to the server to kill the process.

    So I'm trying to limit ffmpeg CPU usage during transcoding.

    I stopped Jellyfin (sudo systemctl stop jellyfin)

    edited /etc/jellyfin/encoding.xml from

    Code:
    <EncoderAppPathDisplay>/usr/lib/jellyfin-ffmpeg/ffmpeg</EncoderAppPathDisplay>

    to

    Code:
    <EncoderAppPathDisplay>/usr/bin/nice -n 19 /usr/lib/jellyfin-ffmpeg/ffmpeg</EncoderAppPathDisplay>

    and restarted jellyfin.

    This isn't working as the line revert back to automatically <EncoderAppPathDisplay>/usr/lib/jellyfin-ffmpeg/ffmpeg</EncoderAppPathDisplay>.

    is there any way I could limit ffmpeg CPU usage to 80% to avoid system become unresponsive? 

    Thanks for the help
    TheDreadPirate
    Offline

    Community Moderator

    Posts: 15,374
    Threads: 10
    Joined: 2023 Jun
    Reputation: 460
    Country:United States
    #2
    2025-02-11, 02:01 PM
    Making changes to the encoder is no longer supported starting with 10.9. Primarily due to security issues in ffmpeg that would not be fixed if custom ffmpeg binaries were allow.

    The CPU usage you are seeing is from the AUDIO being transcoded. This will ALWAYS happen on the CPU. What you can do is enable transcode throttling IN JELLYFIN.

    Dashboard > Playback > Transcoding. Scroll down to the bottom and check "Throttle Transcodes". That should pause ffmpeg after it gets 3 minutes ahead of playback (by default).
    Jellyfin 10.10.7 (Docker)
    Ubuntu 24.04.2 LTS w/HWE
    Intel i3 12100
    Intel Arc A380
    OS drive - SK Hynix P41 1TB
    Storage
        4x WD Red Pro 6TB CMR in RAIDZ1
    [Image: GitHub%20Sponsors-grey?logo=github]
    I-G-1-1
    Offline

    Junior Member

    Posts: 21
    Threads: 2
    Joined: 2023 Jun
    Reputation: 0
    #3
    2025-02-11, 02:27 PM
    Thanks for the answer.

    I knew that for security reason I cannot change the ffmpeg path from the webUI and I was ok with that. However I tought that as root of my server I could change /etc/jellyfin/encoding.xml

    Sorry but this seems an A p p l e move: "my dear user, I know better than you what you could do with your hardware: no option for you".

    Can I use "/etc/systemd/system/jellyfin.service.d/override.conf" to pass --ffmpeg path to the Jellyfin executable?

    Code:
    ExecStart = /usr/bin/jellyfin $JELLYFIN_WEB_OPT $JELLYFIN_FFMPEG_OPT $JELLYFIN_SERVICE_OPT $JELLYFIN_NOWEBAPP_OPT $JELLYFIN_ADDITIONAL_OPTS

    What I have to change in ExecStart? Thanks
    TheDreadPirate
    Offline

    Community Moderator

    Posts: 15,374
    Threads: 10
    Joined: 2023 Jun
    Reputation: 460
    Country:United States
    #4
    2025-02-11, 02:41 PM (This post was last modified: 2025-02-11, 02:44 PM by TheDreadPirate. Edited 1 time in total.)
    You could modify the environment to override. I think $JELLYFIN_FFMPEG_OPT is defined in /etc/default/jellyfin.

    But also give transcode throttling a try.

    We used to make it easy to modify the ffmpeg path but, again, there was a not insignificant security vulnerability in ffmpeg. We backported the patch into jellyfin-ffmpeg, but then came the conversation about users running custom ffmpegs for the lulz. We figured that not making it easy would prevent "for the lulz" users from changing the ffmpeg path, but still allowing the change to be made via the environment file would allow power users to still make a change.
    Jellyfin 10.10.7 (Docker)
    Ubuntu 24.04.2 LTS w/HWE
    Intel i3 12100
    Intel Arc A380
    OS drive - SK Hynix P41 1TB
    Storage
        4x WD Red Pro 6TB CMR in RAIDZ1
    [Image: GitHub%20Sponsors-grey?logo=github]
    I-G-1-1
    Offline

    Junior Member

    Posts: 21
    Threads: 2
    Joined: 2023 Jun
    Reputation: 0
    #5
    2025-02-11, 05:43 PM
    At the end I gave up on trying to add nice/cpulimit to the ffmpeg executable.

    Instead I added to /etc/systemd/system/jellyfin.service.d/override.conf:

    Code:
    [Unit]
    #CPUWeight defaults to 100 for all processes on the system. Setting a low value still lets process use the CPU if nothing else is effectively keeping the system responsive for other tasks while not slowing down the results much. This is a arbitrary weight integer.
    CPUWeight=100
    #CPUQuota is an absolute limit on how much CPU time is granted even if nothing else is going on. This is a percent value. In my case it wasn't really necessary to set this to fix the resource hogging issue.                                                               
    CPUQuota=90%

    I still need to test "transcode throttling". 

    Thanks for the help
    « 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