Jellyfin Forum
High CPU usage - Printable Version

+- Jellyfin Forum (https://forum.jellyfin.org)
+-- Forum: Support (https://forum.jellyfin.org/f-support)
+--- Forum: Troubleshooting (https://forum.jellyfin.org/f-troubleshooting)
+--- Thread: High CPU usage (/t-high-cpu-usage)

Pages: 1 2 3 4


RE: High CPU usage - TheDreadPirate - 2024-01-23

(2024-01-23, 01:35 PM)spanky34 Wrote: Can I DM you the logs? I have multiple users and don't want to publicly post the logs due to potentially identifiable information.  Also... log apparently is too large for both locations.  Might have to truncate the logs into multiple posts.  The logs for the day are about 8MB.

Sure.


RE: High CPU usage - JoeyG1973 - 2024-01-23

Going to throw my interesting discovery in here.

This is happening when I play a 4k steam with subtitles.  It's a .mkv and I thought that having the subtitles extracted would reduce the load, but to no avail.  Guess that subtitles are added to the video stream on the fly, which now that I think about it, is exactly what is happening.  Still it makes no sense why I have such a high cpu load.  I have a Nvidia P400 and before I got CUDA setup working with Jellyfin if I played the same stream with subtitles, it simply would lock up and not play, which makes sense considering I am rocking a "Intel® Core™ i7-4790 CPU @ 3.60GHz".  I know it is working because nvidia-smi says as much.

I would have thought that having all this transcoding off loaded to the GPU would not have impacted the CPU as much as it does.

All this said, videos play smooth with subtitles in 4k on my local network.  Not something I can say worked with Plex.  Same setup with Plex and it was constantly buffering on the client end.

Running straight on Fedora 39.

root@gpm:~# rpm -qa | grep jellyfin
jellyfin-firewalld-10.8.13-1.fc39.noarch
jellyfin-server-10.8.13-1.fc39.x86_64
jellyfin-web-10.8.13-1.fc39.noarch
jellyfin-10.8.13-1.fc39.x86_64

I also hacked /etc/jellyfin/encoding.xml to use the jellyfin-ffmpeg portable I got from here https://github.com/jellyfin/jellyfin-ffmpeg/releases however it doesn't seem that much more efficient than the one that comes with Fedora 39.  And yes you need to hack it into that file because it is not something that you can change from the UI.  Added the following 2 lines.

  <EncoderAppPath>/usr/local/jellyfin-ffmpeg/ffmpeg</EncoderAppPath>
  <EncoderAppPathDisplay>/usr/local/jellyfin-ffmpeg/ffmpeg</EncoderAppPathDisplay>

I want to know why the CPU is still screaming even with the work being offloaded to the GPU.  To add to this after about 15-30 minutes of playing the stream, the ffmpeg just goes away until I stop the client playback and start again.  The box is still snappy though even with all of this CPU load.

Any thoughts on this? 


Code:
root@gpm:~# nvidia-smi
Tue Jan 23 17:27:39 2024
+---------------------------------------------------------------------------------------+
| NVIDIA-SMI 545.29.06              Driver Version: 545.29.06    CUDA Version: 12.3    |
|-----------------------------------------+----------------------+----------------------+
| GPU  Name                Persistence-M | Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf          Pwr:Usage/Cap |        Memory-Usage | GPU-Util  Compute M. |
|                                        |                      |              MIG M. |
|=========================================+======================+======================|
|  0  Quadro P400                    Off | 00000000:01:00.0 Off |                  N/A |
| 43%  53C    P0              N/A /  N/A |    192MiB /  2048MiB |    12%      Default |
|                                        |                      |                  N/A |
+-----------------------------------------+----------------------+----------------------+

+---------------------------------------------------------------------------------------+
| Processes:                                                                            |
|  GPU  GI  CI        PID  Type  Process name                            GPU Memory |
|        ID  ID                                                            Usage      |
|=======================================================================================|
|    0  N/A  N/A    380547      C  /usr/local/jellyfin-ffmpeg/ffmpeg          188MiB |
+---------------------------------------------------------------------------------------+


Running top and I can clearly see that ffmpeg is trying to break the box.
   

htop doesn't look much better
   

This is the full command that is running:

Code:
root@gpm:~# ps -eaf | grep 380547
jellyfin  380547  283992 99 17:27 ?        00:22:28 /usr/local/jellyfin-ffmpeg/ffmpeg -analyzeduration 200M -ss 01:53:21.000 -init_hw_device cuda=cu:0 -filter_hw_device cu -autorotate 0 -canvas_size 2582x1080 -i file:/mnt/data/media/movies/Dune (2021)/Dune.2021.PROPER.UHD.BluRay.2160p.10bit.DoVi.2Audio.TrueHDAtmos.7.1.x265-b.mkv -map_metadata -1 -map_chapters -1 -threads 0 -map 0:0 -map 0:2 -map -0:0 -codec:v:0 h264_nvenc -preset p1 -b:v 54566883 -maxrate 54566883 -bufsize 109133766 -g:v:0 72 -keyint_min:v:0 72 -filter_complex [0:5]scale=s=3840x1606:flags=fast_bilinear[sub];[0:0]setparams=color_primaries=bt709:color_trc=bt709:colorspace=bt709,scale=trunc(min(max(iw\,ih*a)\,min(3840\,1606*a))/2)*2:trunc(min(max(iw/a\,ih)\,min(3840/a\,1606))/2)*2,format=yuv420p[main];[main][sub]overlay=eof_action=endall:shortest=1:repeatlast=0 -start_at_zero -codec:a:0 copy -copyts -avoid_negative_ts disabled -max_muxing_queue_size 2048 -f hls -max_delay 5000000 -hls_time 3 -hls_segment_type mpegts -start_number 2267 -hls_segment_filename /var/lib/jellyfin/transcodes/b98168691b3c4e21493476b9dd6e04c4%d.ts -hls_playlist_type vod -hls_list_size 0 -y /var/lib/jellyfin/transcodes/b98168691b3c4e21493476b9dd6e04c4.m3u8



RE: High CPU usage - TheDreadPirate - 2024-01-23

If you are also transcoding audio, that will occur on the CPU. If your GPU is blowing through the video, your CPU will have to keep up.


RE: High CPU usage - JoeyG1973 - 2024-01-23

How do I know if I am transcoding audio? How come ffmpeg only fires up when I turn on subtitles? I play the same stream, Dolby Digial EX Audio 5.1 @ 448 kbs, both with and without subtitles like as mentioned, it only fires up ffmpeg with subtitles enabled.

My curiosity is killing me here and I am trying to understand. Smiling-face


RE: High CPU usage - TheDreadPirate - 2024-01-24

Depending on the client, when video is transcoded the audio is also transcoded. If you share the ffmpeg log with us we could figure that out.


RE: High CPU usage - joeblackdandt - 2024-03-08

Sorry for jumping in out of nowhere, but I am facing a similar issue, once I start watching something, anything, it just makes the CPU stay above 94% for hours until I end up restarting jellyfin. I am running Jellyfin on Terramaster NAS F2-221. No issues with watching videos, it just triggers the CPU like this. I ran ps aux, result attached.

Thanks in advance


RE: High CPU usage - TheDreadPirate - 2024-03-09

Looks like it is transcoding. Does the CPU usage return to normal after you stop watching the video that triggered the transcode?


RE: High CPU usage - tsgillx - 2024-03-09

No it does not turn to normal. Since I was transitioning from Plex to Jellyfin I left plex running too. Seems like if Plex is running on the TrueNAS server at the same time it causes the high cpu usage. Not sure why. I just turned PLEX off now it is running very smootly.

Now i need to find a way to syn somehow free plex watch history with Jellyfin. I dont have plex pass Smiling-face


RE: High CPU usage - TheDreadPirate - 2024-03-09

How are you installing Jellyfin on your NAS? From Asustor's app store? Or a docker image? If docker, which one? Can Asustor NASes run docker?


RE: High CPU usage - spanky34 - 2024-05-12

Resurfacing to mention I found the source of my issues.

It was related to remote users having content paused and then the screensaver taking over. I FINALLY got everyone to confirm the screensavers are disabled on their AndroidTV clients (firetv and CCWGTV) and the high CPU usage went away. It's been about 10 days of quiet over here.