How do i enable Intel Quick Sync for handbrake docker container?


Recommended Posts

Hi!

When I'm optimizing a video in Plex, an MKV H264 (4GB) takes ~30 min to convert to the 'Phone 1080p' preset. But when I'm using Handbrake (docker container) it seems to never finish, I've let it run for 2h and it still didn't finish. I suspect Handbrake isn't using hardware acceleration (Intel quick sync?). I've read that it should be enabled by default (?). Is there something I need to do to enable it? Thank you!

Link to comment
1 hour ago, cagemaster said:

I suspect Handbrake isn't using hardware acceleration (Intel quick sync?). I've read that it should be enabled by default (?)

No, you have to set up the container to use hardware acceleration.

 

Assuming your CPU supports QSV and that you have configured unRAID to load the i915 drivers, you need to setup a container device that points to /dev/dri

 

image.thumb.png.6dbbba716d22b5b01d2a34559a0b33f6.png

 

If you have QSV properly configured in unRAID and the container, Intel QSV will show up as a video codec you can select in Handbrake

image.png.7c0333588ed935cd77f2421076d3acb8.png

 

Create a custom preset using this codec and save it in HandBrake.

 

If you want your custom preset to be the default for the container, go back to the HandBrake container and specify your preset as the Automatic Video Converter Preset.

 

image.thumb.png.e7e309e4da1cfe074819f6ed5e180143.png

Link to comment

I don't think i have configured unRAID to load the i915 drivers because the container creation fails.

Error response from daemon: error gathering device information while adding custom device "/dev/dri": no such file or directory.

Do you have a good guide on how to do that?

 

I made it work by following a previous tutorial of yours! Thank you.

Edited by cagemaster
Link to comment
7 minutes ago, cagemaster said:

I don't think i have configured unRAID to load the i915 drivers because the container creation fails.


Error response from daemon: error gathering device information while adding custom device "/dev/dri": no such file or directory.

Do you have a good guide on how to do that?

Start a terminal session from unRAID GUI and type

 

modprobe i915

 

if you get no errors, type the following:

 

cd /dev/dri

ls

 

If all is well you should see the files indicated in the /dev/dri folder.

image.png.6571cfdf83b08b947b1d094670fbe604.png

 

If it all looks good and the drivers are loading, you should modify your go file on the flash drive to load the i915 drivers when the server is booted.  I have the following entries in my go file. I am using hardware transcoding in both Plex and HandBrake.

 

#Setup drivers for hardware transcoding in Plex
modprobe i915
sleep 4
chown -R nobody:users /dev/dri
chmod -R 777 /dev/dri

  • Thanks 1
Link to comment
5 hours ago, John_M said:

Do you have to take any special precautions to make sure they never both transcode at the same time, or it is simply not an issue?

I don't think it would be an issue and, frankly, I do not even know if both have been transcoding at the same time. I have never seen any errors or problems.

 

I have had up to six hardware transcodes going simultaneously in Plex and there was PLENTY of overhead left. so, I don' think a HandBrake job kicking off at the same would tax the capabilities of the CPU/iGPU

 

Now I am curious and I will have to do some tests. 😁 

Edited by Hoopster
Link to comment
3 hours ago, John_M said:

Do you have to take any special precautions to make sure they never both transcode at the same time, or it is simply not an issue?

I started two Plex streams forcing a 1080p transcode on both.  I confirmed both streams were being decoded and encoded in hardware (Quick Sync).  I then started a 1080p transcode in HandBrake from .mkv to .mp4 using my Quick Sync Video preset.  It started and ran without any issues even while the two Plex streams continued uninterrupted.  I then started a third Plex stream transcoding 1080p to 720p.

 

I let all the above run for about 20 minutes.  I then cancelled the three Plex streams.  QSV handled the three Plex streams in the iGPU and there was only a minor difference on the overall CPU load with or without the Plex streams running.

 

Most of the load on the CPU (averaged about 74% which is typical for my HandBrake transcodes) was because HandBrake was transcoding subtitles as well as the audio and video tracks.  That uses CPU and is not done in QSV.

 

There are no issues in letting both Plex and HandBrake transcode via QSV simultaneously. 

 

 

  • Thanks 1
Link to comment
  • 3 years later...
i have a similar issues and i am using unraid docker from https://hub.docker.com/r/jlesage/handbrake/ latest v1.5.1 revision.
however intel quick sync is not showing up in video encoder list. i installed GPU top plugin, installed GPU statistic plugging, added /dev/dri/ to docker "device" parameter.
 
also, if type cd /dev/dri>>ls in terminal can see card0/renderD128 means my intel quick sync activated.
furthermore, I have my jellyfin running hardware transcoding with intel quick sync perfectly fine as tracked and shown in the GPU statistic whenever I run a transcoding media stream.
 
then, docker privilege setting is set to enable, also using PUID & PGID of "0". tried both Umask of 000 and 022.
 
However, handbrake just does not work and I am on Unraid Version: 6.11.5
 
Can anyone help to advise how am I going to get intel QSV encoder to show up?
 
the only thing I do not dare to do yet is the following code which I am not sure what this is doing and worry it may mess up my system.
i dont do plex hardware transcoding as i dont have the plex pass.
the question is do i need this "
modprobe i915" thing on my unraid v6.11.5?
 
#Setup drivers for hardware transcoding in Plex
modprobe i915
sleep 4
chown -R nobody:users /dev/dri
chmod -R 777 /dev/dri
Link to comment
  • 4 months later...

I'd like to bump this. I have the same issue as @Alvin Leong except I'm using Plex. HW transcoding works fine but I can't seem to enable quicksync on handbrake. I've added /dev/dri as a handbrake device parameter so if Quicksync works in Plex it should show up here. 

 

I added the below to the "go file" but no joy.

 

modprobe i915
chown -R nobody:users /dev/dri
chmod -R 777 /dev/dri

 

If anyone could provide a steer it would be much appreciated!

Edited by SRTG
Link to comment
3 hours ago, SRTG said:

If anyone could provide a steer it would be much appreciated!

Have you created a preset in HandBrake that uses the QSV encoder?

 

Do QSV encoder options appear in the video encoder list in HandBrake?  If not, the container is not setup properly with /dev/dri

image.png.94a200dff477e2d771030e56c33d7889.png

Link to comment
17 hours ago, Hoopster said:

Have you created a preset in HandBrake that uses the QSV encoder?

 

Do QSV encoder options appear in the video encoder list in HandBrake?  If not, the container is not setup properly with /dev/dri

 

The QSV options don't appear in the dropdown. Mine still look like this:

 

image.png.f80db101e06a83ee2f6dda9e5400da8c.png

I've already added /dev/dri device as below but still no luck. 

 

 image.png.3e5e33682dda589a2b9ce09c0bf9cb71.png

Link to comment
59 minutes ago, SRTG said:

I've already added /dev/dri device as below but still no luck. 

Do you get any errors related to /dev/dri when your Handbrake container starts?  Post your docker run command.

 

In a terminal session, if you type the following commands what do you see?

 

cd /dev/dri

ls

 

You should see the following (card1 does not need to be there).  If you do not see this, your system is not loading the i915 /dev/dri drivers.

 

image.png.332ff9c81ca98f1e4e8058b7d68faddc.png

 

You do not mention what version of Unraid you are running, but from version 6.9.0 and greater, go file entries for modprobe i915 are no longer recommended.; although, I suppose it may still work.  I am using the "touch" method to load i915.  See the release notes for more information.

 

For example, here are the 6.9.0 release notes on GPU drivers:

 

image.thumb.png.e769406efcd342ce22bb99326c66837e.png

 

 

Link to comment
52 minutes ago, Hoopster said:

In a terminal session, if you type the following commands what do you see?

 

cd /dev/dri

ls

 

You should see the following (card1 does not need to be there).  If you do not see this, your system is not loading the i915 /dev/dri drivers.

Yes, in terminal I see card0, render D128. 

 

I'm running UNRAID 6.11.5.

 

I did notice something in handbrake_activity_logs.txt. It seems to confirm QSV is available but it can't locate the driver ? I'm a little confused on how Plex can see this but Handbrake can't.

 

So a possible solution is terminal: touch /boot/config/modprobe.d/i915.conf ?

 

Thanks for your help so far!

Link to comment
On 5/20/2023 at 9:29 AM, SRTG said:

So a possible solution is terminal: touch /boot/config/modprobe.d/i915.conf ?

I just built a new server last week on which I installed Handbrake.  I am running Unraid 6.11.5 on that server.

 

I noticed I had no QSV Handbrake options on that server.  I had no i915.conf file there either; however, I recall that in an Unraid release after 6.9.0 (I do not recall which one), it was mentioned that Unraid would now automatically load the i915 drivers if an iGPU was detected.  As a test of that theory, I did not create an i915.conf file via the touch method on this server.

 

The only thing I did to get the QSV encoder options to show up in Handbrake on this new server was to add the /dev/dri device.  I am currently running a Fast 1080p30 H.265 QSV encode on that server.

 

image.png.a00905b36d8b563b4c404fbeae33cf98.png

 

My /dev/dri device looks no different than yours, yet it works for me and not for you.  Perhaps try posting in the Handbrake support thread?

 

 

Link to comment

@SRTG Of course, you cannot even get the QSV encoding options to show up, but, when you do, here is another tip should you get encoding failures when attempting QSV encoding in Handbrake:

 

I don't know what CPU you are using, but in examining my Handbrake QSV preset, I remembered a setting I needed to add to get QSV to work with the 11th Generation i5-11600 CPU in that system.  Prior to adding this, I would get an "encoding failed" message on all encoding attempts with QSV.

 

Rocket Lake/11th gen CPU/iGPUs had problems with low power QSV encoding which is the default for Handbrake.  I had to turn off low power mode in the QSV presets by adding "lowpower=0' to the "More Settings" box in in the Video tab.  So I did not have to add this each time, I made sure to resave the Preset with this setting.

 

image.thumb.png.3b4a063e4cb64947088e25f11da4f08a.png

Edited by Hoopster
Link to comment

@Hoopster Interesting, I've added this setting.

 

I have an i5-4590 so maybe the fact it's an older QSV processor is an issue in itself !

 

What I've tried so far:

 

-Added "/dev/dri" as a device in handbrake

-Go file modprobe i915 chown -R nobody:users /dev/dri chmod -R 777 

-Tried "--device=/dev/dri/card0:/dev/dri/card0 --device=/dev/dri/renderD128:/dev/dri/renderD128" in extra parameters

-Added blank config file to whitelist the driver "touch /boot/config/modprobe.d/i915.conf"

-Added "i915.alpha_support=1" to syslinux boot

 

Right now I can encode a 2-hour bluray in around 2hrs 15 mins but only in H264 (h265 is at least double this). Not the end of the world but CPU utilisation is a solid 100%. QSV should cut the time down and give me some headroom!

 

I will try handbrake forums and post a solution if I ever find one. 

Link to comment
2 hours ago, SRTG said:

I have an i5-4590 so maybe the fact it's an older QSV processor is an issue in itself !

Yes, that is the problem.  According to the Handbrake documentation, at least a 6th generation CPU/iGPU is required for QSV support.

 

From the documentation:

 

Intel Quick Sync Video

Supported Hardware and Configurations

  • Intel Skylake (6th Generation Core) CPU or later with Intel HD, Iris Xe or Arc graphics.
Link to comment
  • 1 month later...

I'm going to drop some head pounding, time sucking, information that has taken me the better part of 2 days to figure out, and every time I went searching this thread kept coming up so I feel this may be the best place to drop it for any future poor soul that tries to figure it out.  

 

I have been trying to figure out why my 10th gen Intel Celeron Elkhart Lake J6413 would not show the QSV options.  Even though in handbrakes activity screen it says "qsv is available on this system", I went down every rabbit hole, every random thread I could find.  I followed all the things in this thread even though I'm running 6.11.5 and some of the things weren't needed. 

 

I think the main issue I was running into was the fact that my CPU/GPU only supports low power mode (according to the jellyfin documentation).  Which when I was running my server off of an i7-8700T, I never had a single issue, and the QSV options just came up.  

 

When I was on the handbrake site looking at the QSV documentation, 

https://handbrake.fr/docs/en/latest/technical/video-qsv.html

 

There was a link to a github "Known Issues and Limitations" for intel media drivers.

https://github.com/intel/media-driver#known-issues-and-limitations

1629266046_Screenshot2023-07-07152939.thumb.png.19739a3a0b5a141450f34ec829adf595.png

 

 

This got me trying to put "options i915 enable_guc=2" in all the locations the "i915.conf" file may live.  

 

What ended up working for me was putting "options i915 enable_guc=2" in the /boot/config/modprobe.d/i915.conf. This does copy down to the /etc/modprobe.d/i915.conf on reboot.

 

1351045178_Screenshot2023-07-07153320a.png.7d8c3fa561ea79f214933dd27edba0e4.png

 

 

I hope this can help anyone in the future if you come upon this. 

 

 

 

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.