Jellyfin Forum
SOLVED: Jellyfin buffering... is my hardware acceleration working? - 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: SOLVED: Jellyfin buffering... is my hardware acceleration working? (/t-solved-jellyfin-buffering-is-my-hardware-acceleration-working)

Pages: 1 2


Jellyfin buffering... is my hardware acceleration working? - RitzyMage - 2024-08-27

I've been running my Jellyfin server for a while now and for the most part things are going great! However, sometimes when streaming, the server will stutter or just stop to buffer for quite a while. I *supposedly* have hardware acceleration working, but I'm not 100% sure it is. So a few questions:

  1. If hardware acceleration is working, will Jellyfin lower the resolution of the stream instead of buffering?
  2. In either case, how do I verify that hardware acceleration is actually happening?

I'm suspicious that hardware acceleration isn't working because of (1) the buffering and (2) when I check my GPU's usage with intel_gpu_top, I see this:
Code:
intel-gpu-top: Intel Dg2 (Gen12) @ /dev/dri/card0 -    0/  0 MHz; 100% RC6;        0 irqs/s
      IMC reads:        0 MiB/s
    IMC writes:        0 MiB/s
        ENGINES    BUSY                                                                                                                                                                                                                                                MI_SEMA MI_WAIT
      Render/3D    0.00% |                                                                                                                                                                                                                                            |      0%      0%
        Blitter    0.00% |                                                                                                                                                                                                                                            |      0%      0%
          Video    0.00% |                                                                                                                                                                                                                                            |      0%      0%
    VideoEnhance    0.00% |                                                                                                                                                                                                                                            |      0%      0%
      [unknown]    0.00% |

All of the usage remains at 0.00%, even when streaming.

Details: 

Jellyfin versions (obtained through the AUR):
Code:
jellyfin-bin                       10.8.9-1                              
jellyfin-ffmpeg                    1:6.0.1p8-1

OS Versions (I'm running Manjaro):

Code:
[me@jellyfin ~]$ lsb_release -a
LSB Version:    n/a
Distributor ID: ManjaroLinux
Description:    Manjaro Linux
Release:        24.0.7
Codename:       Wynsdey
[me@jellyfin ~]$ mhwd-kernel -li  
Currently running: 6.1.105-1-MANJARO (linux61)

Hardware Acceleration Configuration:

(screenshot attached)

Outputs of the commands given in the hardware acceleration documentation:

Code:
[me@jellyfin ~]$ ls -l /dev/dri
total 0
drwxr-xr-x 2 root root        80 Aug 25 13:15 by-path
crw-rw---- 1 root video  226,  0 Aug 25 13:15 card0
crw-rw-rw- 1 root render 226, 128 Aug 25 13:15 renderD128

(looks normal to me)

/usr/lib/jellyfin-ffmpeg/vainfo doesn't exist (even though /usr/lib/jellyfin-ffmpeg/does), but I can run regular vainfo:
Code:
$ sudo vainfo --display drm --device /dev/dri/renderD128
Trying display: drm
vainfo: VA-API version: 1.22 (libva 2.22.0)
vainfo: Driver version: Intel iHD driver for Intel(R) Gen Graphics - 24.2.5 ()
vainfo: Supported profile and entrypoints
      VAProfileNone                  : VAEntrypointVideoProc
      VAProfileNone                  : VAEntrypointStats
      VAProfileMPEG2Simple            : VAEntrypointVLD
      VAProfileMPEG2Main              : VAEntrypointVLD
      VAProfileH264Main              : VAEntrypointVLD
      VAProfileH264Main              : VAEntrypointEncSliceLP
      VAProfileH264High              : VAEntrypointVLD
      VAProfileH264High              : VAEntrypointEncSliceLP
      VAProfileJPEGBaseline          : VAEntrypointVLD
      VAProfileJPEGBaseline          : VAEntrypointEncPicture
      VAProfileH264ConstrainedBaseline: VAEntrypointVLD
      VAProfileH264ConstrainedBaseline: VAEntrypointEncSliceLP
      VAProfileHEVCMain              : VAEntrypointVLD
      VAProfileHEVCMain              : VAEntrypointEncSliceLP
      VAProfileHEVCMain10            : VAEntrypointVLD
      VAProfileHEVCMain10            : VAEntrypointEncSliceLP
      VAProfileVP9Profile0            : VAEntrypointVLD
      VAProfileVP9Profile1            : VAEntrypointVLD
      VAProfileVP9Profile2            : VAEntrypointVLD
      VAProfileVP9Profile3            : VAEntrypointVLD
      VAProfileHEVCMain12            : VAEntrypointVLD
      VAProfileHEVCMain422_10        : VAEntrypointVLD
      VAProfileHEVCMain422_10        : VAEntrypointEncSliceLP
      VAProfileHEVCMain422_12        : VAEntrypointVLD
      VAProfileHEVCMain444            : VAEntrypointVLD
      VAProfileHEVCMain444            : VAEntrypointEncSliceLP
      VAProfileHEVCMain444_10        : VAEntrypointVLD
      VAProfileHEVCMain444_10        : VAEntrypointEncSliceLP
      VAProfileHEVCMain444_12        : VAEntrypointVLD
      VAProfileHEVCSccMain            : VAEntrypointVLD
      VAProfileHEVCSccMain            : VAEntrypointEncSliceLP
      VAProfileHEVCSccMain10          : VAEntrypointVLD
      VAProfileHEVCSccMain10          : VAEntrypointEncSliceLP
      VAProfileHEVCSccMain444        : VAEntrypointVLD
      VAProfileHEVCSccMain444        : VAEntrypointEncSliceLP
      VAProfileAV1Profile0            : VAEntrypointVLD
      VAProfileAV1Profile0            : VAEntrypointEncSliceLP
      VAProfileHEVCSccMain444_10      : VAEntrypointVLD
      VAProfileHEVCSccMain444_10      : VAEntrypointEncSliceLP

which implies that the H264 codec *should* be supported.

Code:
$ sudo /usr/lib/jellyfin-ffmpeg/ffmpeg -v verbose -init_hw_device vaapi=va:/dev/dri/renderD128 -init_hw_device opencl@va
ffmpeg version 6.0.1-Jellyfin Copyright (c) 2000-2023 the FFmpeg developers
  built with gcc 14.1.1 (GCC) 20240720
  configuration: --prefix=/usr/lib/jellyfin-ffmpeg --target-os=linux --extra-version=Jellyfin --disable-doc --disable-ffplay --disable-ptx-compression --disable-shared --disable-libxcb --disable-sdl2 --disable-xlib --enable-gpl --enable-version3 --enable-static --enable-gmp --enable-gnutls --enable-chromaprint --enable-libfontconfig --enable-libass --enable-libbluray --enable-libdrm --enable-libfreetype --enable-libfribidi --enable-libmp3lame --enable-libopus --enable-libopenmpt --enable-libtheora --enable-libvorbis --enable-libdav1d --enable-libwebp --enable-libvpx --enable-libx264 --enable-libx265 --enable-libzvbi --enable-libzimg --enable-libshaderc --enable-libplacebo --enable-vulkan --enable-opencl --enable-vaapi --enable-amf --enable-libvpl --enable-ffnvcodec --enable-cuda --enable-cuda-llvm --enable-cuvid --enable-nvdec --enable-nvenc
  libavutil      58.  2.100 / 58.  2.100
  libavcodec    60.  3.100 / 60.  3.100
  libavformat    60.  3.100 / 60.  3.100
  libavdevice    60.  1.100 / 60.  1.100
  libavfilter    9.  3.100 /  9.  3.100
  libswscale      7.  1.100 /  7.  1.100
  libswresample  4. 10.100 /  4. 10.100
  libpostproc    57.  1.100 / 57.  1.100
[AVHWDeviceContext @ 0x558b204ccfc0] libva: VA-API version 1.22.0
[AVHWDeviceContext @ 0x558b204ccfc0] libva: Trying to open /usr/lib/dri/iHD_drv_video.so
[AVHWDeviceContext @ 0x558b204ccfc0] libva: Found init function __vaDriverInit_1_21
[AVHWDeviceContext @ 0x558b204ccfc0] libva: va_openDriver() returns 0
[AVHWDeviceContext @ 0x558b204ccfc0] Initialised VAAPI connection: version 1.22
[AVHWDeviceContext @ 0x558b204ccfc0] VAAPI driver: Intel iHD driver for Intel(R) Gen Graphics - 24.2.5 ().
[AVHWDeviceContext @ 0x558b204ccfc0] Driver not found in known nonstandard list, using standard behaviour.
[AVHWDeviceContext @ 0x558b204fe300] 0.0: Intel(R) OpenCL Graphics / Intel(R) Arc(TM) A310 LP Graphics
[AVHWDeviceContext @ 0x558b204fe300] Intel QSV to OpenCL mapping function found (clCreateFromVA_APIMediaSurfaceINTEL).
[AVHWDeviceContext @ 0x558b204fe300] Intel QSV in OpenCL acquire function found (clEnqueueAcquireVA_APIMediaSurfacesINTEL).
[AVHWDeviceContext @ 0x558b204fe300] Intel QSV in OpenCL release function found (clEnqueueReleaseVA_APIMediaSurfacesINTEL).
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...

Use -h to get full help or, even better, run 'man ffmpeg'

And I have the items listed as required in the docs:

An example file that buffers


Running ffprobe on a file that buffered gave the following:
Code:
ffprobe version n7.0.1 Copyright (c) 2007-2024 the FFmpeg developers
  built with gcc 14.1.1 (GCC) 20240522
  configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-amf --enable-avisynth --enable-cuda-llvm --enable-lto --enable-fontconfig --enable-frei0r --enable-gmp --enable-gpl --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libdav1d --enable-libdrm --enable-libdvdnav --enable-libdvdread --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libharfbuzz --enable-libiec61883 --enable-libjack --enable-libjxl --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libplacebo --enable-libpulse --enable-librav1e --enable-librsvg --enable-librubberband --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpl --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxml2 --enable-libxvid --enable-libzimg --enable-mbedtls --enable-nvdec --enable-nvenc --enable-opencl --enable-opengl --enable-shared --enable-vapoursynth --enable-version3 --enable-vulkan
  libavutil      59.  8.100 / 59.  8.100
  libavcodec    61.  3.100 / 61.  3.100
  libavformat    61.  1.100 / 61.  1.100
  libavdevice    61.  1.100 / 61.  1.100
  libavfilter    10.  1.100 / 10.  1.100
  libswscale      8.  1.100 /  8.  1.100
  libswresample  5.  1.100 /  5.  1.100
  libpostproc    58.  1.100 / 58.  1.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '<<title>>.mp4':
  Metadata:
    major_brand    : mp42
    minor_version  : 512
    compatible_brands: mp42iso2avc1mp41
    creation_time  : 2024-07-04T16:27:07.000000Z
    title          : <<title>>
    encoder        : HandBrake 1.7.3 2024021100
  Duration: 00:10:56.81, start: 0.000000, bitrate: 1891 kb/s
  Stream #0:0[0x1](und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 1722 kb/s, 23.98 fps, 23.98 tbr, 90k tbn (default)
      Metadata:
        creation_time  : 2024-07-04T16:27:07.000000Z
        handler_name    : VideoHandler
        vendor_id      : [0][0][0][0]
  Stream #0:1[0x2](eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 162 kb/s (default)
      Metadata:
        creation_time  : 2024-07-04T16:27:07.000000Z
        handler_name    : Original
        vendor_id      : [0][0][0][0]

So the encoding looks like it's just normal h264.

Logs
An anonymized log is attached


RE: Jellyfin buffering... is my hardware acceleration working? - TheDreadPirate - 2024-08-27

1) Your kernel is not new enough.  Intel Arc requires kernel 6.2+.
---1a) If you were to run a newer kernel, you only need to worry about installing the intel-opencl-icd package.  Jellyfin-ffmpeg6 comes bundled with all the other Intel drivers you need.

2) HOWEVER, that doesn't matter since the log you shared shows that every video played was direct played.  So you won't see any usage in intel_gpu_top.

Are you using a reverse proxy?  If so, is it running on the same host as Jellyfin?


RE: Jellyfin buffering... is my hardware acceleration working? - RitzyMage - 2024-08-28

(2024-08-27, 11:29 PM)TheDreadPirate Wrote: 1) Your kernel is not new enough.  Intel Arc requires kernel 6.2+.
---1a) If you were to run a newer kernel, you only need to worry about installing the intel-opencl-icd package.  Jellyfin-ffmpeg6 comes bundled with all the other Intel drivers you need.

2) HOWEVER, that doesn't matter since the log you shared shows that every video played was direct played.  So you won't see any usage in intel_gpu_top.

Are you using a reverse proxy?  If so, is it running on the same host as Jellyfin?

I am using a nginx on our host to proxy to jellyfin (so that we can connect using HTTPS on port 443).

And are you saying that if I upgrade my kernel, then the hardware acceleration should work?


RE: Jellyfin buffering... is my hardware acceleration working? - TheDreadPirate - 2024-08-28

It should, yes. But, as I stated, in the log you shared all of the videos you watched were direct played. No transcoding, no CPU usage, no GPU usage. The server is just straight up sending the file to the client unmodified. Whatever is going on with the buffering is not GPU/hardware acceleration related. But you should get that squared away anyway so that it is there when needed.

Are all of your clients using your domain name to access Jellyfin? Do you experience buffering only when you're not at home? Or does it also happen with local clients on the same LAN?


RE: Jellyfin buffering... is my hardware acceleration working? - RitzyMage - 2024-08-28

(2024-08-28, 12:15 AM)TheDreadPirate Wrote: ...all of the videos you watched were direct played. No transcoding, no CPU usage, no GPU usage. The server is just straight up sending the file to the client unmodified.

Oh I see. I thought sending the file was what it did as opposed to GPU encoding. So getting the video to encode at all is a separate issue from the hardware acceleration.

(2024-08-28, 12:15 AM)TheDreadPirate Wrote: Are all of your clients using your domain name to access Jellyfin?  Do you experience buffering only when you're not at home?  Or does it also happen with local clients on the same LAN?

They are all using the domain name. Buffering can happen when I am at home, but I think it is a bit more common on the network.


RE: Jellyfin buffering... is my hardware acceleration working? - TheDreadPirate - 2024-08-28

I'm wondering if your local traffic is not staying local.  Does your router support NAT loopback/hairpin?  Enabling them would keep local traffic from going out to the Internet and coming back.

For your remote clients, how fast is your home Internet connection?  And can you provide the media info for some of your problem videos?


   


RE: Jellyfin buffering... is my hardware acceleration working? - RitzyMage - 2024-08-28

(2024-08-28, 12:54 AM)TheDreadPirate Wrote: I'm wondering if your local traffic is not staying local.  Does your router support NAT loopback/hairpin?  Enabling them would keep local traffic from going out to the Internet and coming back.

It's definitely possible; my router should have NAT capabilities according to the docs, but I don't see anything in the settings.

(2024-08-28, 12:54 AM)TheDreadPirate Wrote: For your remote clients, how fast is your home Internet connection? 

My internet where the server is is a gigabit ethernet connection. Some remote clients have been using a slow connection, which is one reason why I want to get this working.

I've been testing a slower connection using a VPN, but even that is getting ~650 Mbps.

(2024-08-28, 12:54 AM)TheDreadPirate Wrote: And can you provide the media info for some of your problem videos?

Attached a screenshot. My original post also had the output of ffprobe if you want that information.


Code:
Container: mp4
Path: /media/....mp4
Size: 148 MB

Video
Title: 1080p H264 SDR
Codec: H264
Codec tag: avc1
AVC: Yes
Profile: Main
Level: 40
Resolution: 1920x1080
Aspect ratio: 16:9
Interlaced: No
Framerate: 23.976025
Bitrate: 1722 kbps
Bit depth: 8 bit
Video range: SDR
Video range type: SDR
Color space: bt709
Color transfer: bt709
Color primaries: bt709
Pixel format: yuv420p
Ref frames: 1
NAL: 4

Audio
Title: Original - English - AAC - Stereo - Default
Language: eng
Codec: AAC
Codec tag: mp4a
Profile: LC
Layout: stereo
Channels: 2 ch
Bitrate: 162 kbps
Sample rate: 48000 Hz
Video range: Unknown
Video range type: Unknown
Default: Yes
Forced: No
External: No

Also, I just upgraded my Linux kernel version, so I'll see if that helps later today.


RE: Jellyfin buffering... is my hardware acceleration working? - TheDreadPirate - 2024-08-28

I had assumed this would be like a 50-60Mbps 4K remux or something. 1.7Mbps should be easy.

On another PC on your LAN use traceroute to see if traffic stays local.

Circling back to transcoding. Took a look again at your screenshot, update it to this.

Decoding codecs: Check all the boxes except VP8 and VC-1.
Check both low power encoding boxes. It is required for Arc.
Check Allow encoding in HEVC and AV1.
Check both VPP tone mapping and tone mapping.

Recommendations:
Enable transcode throttling
Enable delete segments.


RE: Jellyfin buffering... is my hardware acceleration working? - RitzyMage - 2024-08-28

(2024-08-28, 03:17 PM)TheDreadPirate Wrote: Took a look again at your screenshot, update it to this.

Decoding codecs:  Check all the boxes except VP8 and VC-1.
Check both low power encoding boxes.  It is required for Arc.
Check Allow encoding in HEVC and AV1.
Check both VPP tone mapping and tone mapping.

Recommendations:
Enable transcode throttling
Enable delete segments.

Did all of this except for the "delete segments" part; I don't see that setting.

When running, I didn't see any buffering (but not sure if I just got lucky). I was runinng intel_gpu_top and saw this:

Code:
intel-gpu-top: Intel Dg2 (Gen12) @ /dev/dri/card0 -    0/  0 MHz;  0% RC6;        0 irqs/s

      IMC reads:      21 MiB/s
    IMC writes:        5 MiB/s

        ENGINES    BUSY                                                                                                MI_SEMA MI_WAIT
      Render/3D    0.00% |                                                                                            |      0%      0%
        Blitter    0.00% |                                                                                            |      0%      0%
          Video    0.00% |                                                                                            |      0%      0%
    VideoEnhance    0.00% |                                                                                            |      0%      0%
      [unknown]    0.00% |                                                                                            |      0%      0%

  PID              NAME      Render/3D              Blitter                Video              VideoEnhance          [unknown]         
  555              Xorg |                    ||                    ||                    ||                    ||                    |
  630        ksplashqml |                    ||                    ||                    ||                    ||                    |
  697        ksmserver |                    ||                    ||                    ||                    ||                    |
  699            kded6 |                    ||                    ||                    ||                    ||                    |
  700          kwin_x11 |                    ||                    ||                    ||                    ||                    |
  714      plasmashell |                    ||                    ||                    ||                    ||                    |
  731  kactivitymanage |                    ||                    ||                    ||                    ||                    |
  765  polkit-kde-auth |                    ||                    ||                    ||                    ||                    |
  766  org_kde_powerde |                    ||                    ||                    ||                    ||                    |
  768  xdg-desktop-por |                    ||                    ||                    ||                    ||                    |
  912  msm_kde_notifie |                    ||                    ||                    ||                    ||                    |
  913      kdeconnectd |                    ||                    ||                    ||                    ||                    |
  934          kaccess |                    ||                    ||                    ||                    ||                    |
  935  pamac-tray-plas |                    ||                    ||                    ||                    ||                    |
  1185  kscreenlocker_g |                    ||                    ||                    ||                    ||                    |

The fact that it shows processes at the bottom (which it did not before) is probably a result of updating my linux kernel. Thanks for that suggestion!

When streaming, I did not see jellyfin as a process in that list on the bottom and the usage stayed at 0%. The IMC reads and writes did go up, so maybe that means something? Also, the transcodes directory is empty even when streaming, so I suspect that it's still not encoding.

Is there any more information I could provide?


RE: Jellyfin buffering... is my hardware acceleration working? - TheDreadPirate - 2024-08-28

You would see an ffmpeg process if it was transcoding.  But you probably aren't transcoding, based on what I saw in your last post, so you wouldn't see ffmpeg in intel_gpu_top.

(2024-08-28, 10:57 PM)RitzyMage Wrote: Did all of this except for the "delete segments" part; I don't see that setting.

I just noticed you are on 10.8.9, which is why you don't see "delete segments".  That was added in 10.9.

I highly recommend you upgrade to 10.9.10.  At a minimum, 10.8.13.  There were several security vulnerabilities that were patched leading up to 10.8.13.  And the problem you are having may have been a bug that's been resolved in a later release.  Your specs and your Internet connection seem to be up to the task for the media you are serving.

Regardless if you stick with 10.8.13 or upgrade to 10.9.10, backup your jellyfin data.

/var/lib/jellyfin
/etc/jellyfin

Both of those directories contain your permanent Jellyfin data and your configs, respectively.