xemle / home-gallery

Self-hosted open-source web gallery to view your photos and videos featuring mobile-friendly, tagging and AI powered image discovery
https://home-gallery.org
MIT License
795 stars 58 forks source link

Docker image variant for Intel QuickSync transcoding #146

Open hueyyeng opened 1 month ago

hueyyeng commented 1 month ago

First of all, great work on this project!

I'm curious if there is a plan to offer an option that supports Intel QuickSync (not limited to others hardware acceleration like Nvenc)?

Reason is I'm dabbling with home lab server and I got Jellyfin running with Intel QuickSync through Docker using linuxserver image: https://hub.docker.com/r/linuxserver/jellyfin

Currently I'm using your xemle/home-gallery image and realise it is using node alpine as the base image that I suspects is the culprit as there is no working driver in the docker image when trying to use QuickSync through the video extractor ffmpeg args.

Here's the error message when I try to run ffmpeg inside the container:

[AVHWDeviceContext @ 0x7f2cc24a7f80] libva: VA-API version 1.21.0
[AVHWDeviceContext @ 0x7f2cc24a7f80] libva: User requested driver 'iHD'
[AVHWDeviceContext @ 0x7f2cc24a7f80] libva: Trying to open /usr/lib/dri/iHD_drv_video.so
[AVHWDeviceContext @ 0x7f2cc24a7f80] libva: va_openDriver() returns -1
[AVHWDeviceContext @ 0x7f2cc24a7f80] Failed to initialise VAAPI connection: -1 (unknown libva error).
Device creation failed: -5.
Failed to set value '/dev/dri/renderD128' for option 'qsv_device': I/O error
Error parsing global options: I/O error

The command that I used that works in the Jellyfin container but produce the error above in HomeGallery container:

ffmpeg -loglevel verbose -hwaccel qsv -qsv_device /dev/dri/renderD128 -hwaccel_output_format vaapi -i "foo.mkv" foo.mp4

As I'm familiar with Docker, I'll try to modify the Dockerfile and see how it goes. Probably I'll need to refer to the Jellyfin Dockerfile too to see if I need to do anything extra.

Thanks again for this great project! Images just works but I wanted to include videos that got me noticed the max out CPU usage from ffmpeg conversion that got me disabling the video extraction temporarily.

xemle commented 1 month ago

Hi @hueyyeng Thank you for reaching out and trying HomeGallery

Is that kind of FYI since you are trying to build your own Docker container? Or do you need any support?

Regarding Intel QuickSync I can not help here because I do not own such hardware.

hueyyeng commented 1 month ago

This is more of trying to get Intel QuickSync working inside the Docker container as the ffmpeg args is helpful if one want to utilise the hardware encoding.

I'll share my results here once I got it working so others can benefit from it.


Edit: I manage to use linuxserver/ffmpeg image as my base and manually added node for the gallery image. Although I kept encountering ffmpeg exit code errors when debugging the video extractor.

Turns out the video extractor plugin uses fluent ffmpeg and I need to add inputOptions to the command which got it working.

I need to check the documentation for writing plugins but the only changes I did is the inputOptions after checking fluent ffmpeg docs.

I'll share my solution later once I done a few more testing but for others who are interested in getting a working Intel QuickSync transcoding for homegallery in Docker (before I forget):

  1. Prepare a new Dockerfile or make a copy of the existing Dockerfile. I recommend cloning with git and directly modify the existing Dockerfile as I can track the diff using git.
  2. Use linuxserver/ffmpeg docker image as your base.
  3. Add node and yarn. I'm using node bookworm slim Dockerfile.
  4. Once build, enter the gallery container using bash and verify ffmpeg with QuickSync encoding is working.

Make sure to pass the Intel GPU device to the docker.