Jump to content

HW Transcoding not working


fkp

Recommended Posts

Hi,

 

I'm trying to use HW Transcode without success and I need help.

 

I'm using Debian 8 with emby server 3.2.25.

I have a kernel 4.4 patched for QSV, installation is OK tests OK

I have compiled ffmpeg with QSV support, tests OK

 

My issue is when I select Intel Quick Sync or VAAPI, I have no video playback.

 

the reason is quite simple, ffmpeg can not open /dev/dri/* as emby user

the command extracted from emby's log :

 

 

/home/ffmpeg/3.2.4/ffmpeg -c:v h264_qsv  -i file:"/video/movie.mkv" -map_metadata -1 -map_chapters -1 -threads 0 -map 0:0 -map 0:1 -map -0:s -codec:v:0 h264_qsv -preset 7 -look_ahead 0 -b:v 4616001 -maxrate 4616001 -bufsize 9232002 -profile:v high -level 4.1 -force_key_frames "expr:gte(t,n_forced*3)" -vf "scale=trunc(min(max(iw\,ih*dar)\,3840)/2)*2:trunc(ow/dar/2)*2" -copyts -vsync -1 -codec:a:0 aac -strict experimental -ac 6 -ab 384000  -f segment -max_delay 5000000 -avoid_negative_ts disabled -start_at_zero -segment_time 3  -individual_header_trailer 0 -segment_format mpegts -segment_list_type m3u8 -segment_start_number 0 -segment_list "/var/lib/emby-server/transcoding-temp/5c0682de230cb5847b5a3c37c2a54f83.m3u8" -y "/var/lib/emby-server/transcoding-temp/5c0682de230cb5847b5a3c37c2a54f83%d.ts"

gives :

 

......

libva info: VA-API version 0.99.0
libva info: va_getDriverName() returns 0
libva info: User requested driver 'iHD                  '
libva info: Trying to open /opt/intel/mediasdk/lib64  /iHD                  _drv_video.so
libva info: va_openDriver() returns -1
[h264_qsv @ 0x2db02e0] mfx init: /dev/dri/renderD128 vaInitialize failed
[h264_qsv @ 0x2db02e0] mfx init: /dev/dri/renderD129 fd open failed
[h264_qsv @ 0x2db02e0] mfx init: /dev/dri/renderD130 fd open failed

 

if I cut/paste the same command and run it as root it works

 

libva info: VA-API version 0.99.0
libva info: va_getDriverName() returns 0
libva info: User requested driver 'iHD'
libva info: Trying to open /opt/intel/mediasdk/lib64/iHD_drv_video.so
libva info: Found init function __vaDriverInit_0_32
libva info: va_openDriver() returns 0
Output #0, segment, to '/var/lib/emby-server/transcoding-temp/5c0682de230cb5847b5a3c37c2a54f83%d.ts':
  Metadata:
    encoder         : Lavf57.56.101
    Stream #0:0: Video: h264 (h264_qsv), nv12, 1920x1080 [sAR 1:1 DAR 16:9], q=2-31, 4616 kb/s, 25 fps, 90k tbn, 25 tbc
    Metadata:
      encoder         : Lavc57.64.101 h264_qsv
    Side data:
      cpb: bitrate max/min/avg: 4616001/0/4616001 buffer size: 9232002 vbv_delay: -1
    Stream #0:1: Audio: aac (LC), 48000 Hz, 5.1, fltp (16 bit), 384 kb/s
    Metadata:
      encoder         : Lavc57.64.101 aac
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (h264_qsv) -> h264 (h264_qsv))
  Stream #0:1 -> #0:1 (dts (dca) -> aac (native))

libva info: VA-API version 0.99.0
libva info: va_getDriverName() returns 0
libva info: User requested driver 'iHD'
libva info: Trying to open /opt/intel/mediasdk/lib64/iHD_drv_video.so
libva info: Found init function __vaDriverInit_0_32
libva info: va_openDriver() returns 0
Input stream #0:0 frame changed from size:1920x1080 fmt:yuv420p to size:1920x1080 fmt:nv12
frame=  904 fps=130 q=-0.0 Lsize=N/A time=00:00:36.54 bitrate=N/A speed=5.25x
video:20376kB audio:1247kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown

 

I have the same issue with vainfo ( gives information with root and none with non root user ).

 

So I understand my problem is not linked to emby but perhaps someone here has found a solution.

 

and :

 

* I don't want to run emby as root

* My server has no display ( no X running )

* emby user is in the video group

 

# ls -l /dev/dri
total 0
crw-rw-rw- 1 root video 226,   0 juil. 10 17:51 card0
crw-rw-rw- 1 root video 226,  64 juil. 10 17:51 controlD64
crw-rw-rw- 1 root video 226, 128 juil. 10 17:51 renderD128

 

 

Thanks !

Edited by fkp
Link to comment
Share on other sites

dcrdev

^ Yes that would look to be the case, although the OP said that the emby user is part of the video group.

 

According to the above the rendering device is both owned by the video group and has the requisite permission to access it. Did you restart the emby service after adding the emby user to the group?

Link to comment
Share on other sites

mastrmind11

According to Google there was also an ffmpeg bug a year or so ago that output this error which has supposedly been fixed in later versions.  What version of ffmpeg are you compiling?

Link to comment
Share on other sites

Sounds like the emby service user does not have permission for this, no?

sure :-)

 

^ Yes that would look to be the case, although the OP said that the emby user is part of the video group.

 

According to the above the rendering device is both owned by the video group and has the requisite permission to access it. Did you restart the emby service after adding the emby user to the group?

yes, I have this problem for months now :-(

 

According to Google there was also an ffmpeg bug a year or so ago that output this error which has supposedly been fixed in later versions.  What version of ffmpeg are you compiling?

3.2.4

 

I will try to update my version.

 

Try installing the ffmpeg version from ppa:jonathonf/ffmpeg-3

installation of this package does not work on my system ( no jessie amd64 version ?? ), but I will retry today.

 

Thank you all for your support.

Edited by fkp
Link to comment
Share on other sites

Moved to debian 9 and tried VAAPI, still the same kind of issue 

:(

 

 

vainfo

PuTTY X11 proxy: unable to connect to forwarded X server: Network error: Connection refused

error: can't connect to X server!

libva info: VA-API version 0.99.0

libva info: va_getDriverName() returns 0

libva info: User requested driver 'iHD'

libva info: Trying to open /opt/intel/mediasdk/lib64/iHD_drv_video.so

libva info: Found init function __vaDriverInit_0_32

libva info: va_openDriver() returns 0

vainfo: VA-API version: 0.99 (libva 1.7.3)

vainfo: Driver version: 16.4.4.47109-ubit

vainfo: Supported profile and entrypoints

      VAProfileH264Baseline           : VAEntrypointEncSlice

      VAProfileH264Baseline           : VAEntrypointEncSliceLP

      VAProfileH264Baseline           : <unknown entrypoint>

      VAProfileH264ConstrainedBaseline: VAEntrypointVLD

      VAProfileH264ConstrainedBaseline: VAEntrypointEncSlice

      VAProfileH264ConstrainedBaseline: VAEntrypointEncSliceLP

      VAProfileH264ConstrainedBaseline: <unknown entrypoint>

      VAProfileH264Main               : VAEntrypointVLD

      VAProfileH264Main               : VAEntrypointEncSlice

      VAProfileH264Main               : VAEntrypointEncSliceLP

      VAProfileH264Main               : <unknown entrypoint>

      VAProfileH264High               : VAEntrypointVLD

      VAProfileH264High               : VAEntrypointEncSlice

      VAProfileH264High               : VAEntrypointEncSliceLP

      VAProfileH264High               : <unknown entrypoint>

      VAProfileMPEG2Simple            : VAEntrypointEncSlice

      VAProfileMPEG2Simple            : VAEntrypointVLD

      VAProfileMPEG2Main              : VAEntrypointEncSlice

      VAProfileMPEG2Main              : VAEntrypointVLD

      VAProfileVC1Advanced            : VAEntrypointVLD

      VAProfileVC1Main                : VAEntrypointVLD

      VAProfileVC1Simple              : VAEntrypointVLD

      VAProfileJPEGBaseline           : VAEntrypointVLD

      VAProfileJPEGBaseline           : VAEntrypointEncPicture

      VAProfileVP8Version0_3          : VAEntrypointEncSlice

      VAProfileVP8Version0_3          : VAEntrypointVLD

      VAProfileVP8Version0_3          : <unknown entrypoint>

      VAProfileHEVCMain               : VAEntrypointEncSlice

      VAProfileVP9Profile0            : VAEntrypointEncSlice

      VAProfileVP9Profile0            : VAEntrypointVLD

      VAProfileVP9Profile0            : <unknown entrypoint>

      <unknown profile>               : VAEntrypointVideoProc

      VAProfileNone                   : VAEntrypointVideoProc

      VAProfileNone                   : <unknown entrypoint>

 

 

 

/home/ffmpeg/ffmpeg-git-20170118-64bit-static/ffmpeg -hwaccel vaapi -hwaccel_output_format vaapi -vaapi_device /dev/dri/renderD128 -i file:"/video/movie.mkv" -map_metadata -1 -map_chapters -1 -threads 0 -map 0:0 -map 0:1 -map -0:s -codec:v:0 h264_vaapi  -b:v 3616000 -maxrate 3616000 -bufsize 7232000 -level 41 -force_key_frames "expr:gte(t,n_forced*3)" -vf "format=nv12|vaapi,hwupload" -copyts -vsync -1 -codec:a:0 aac -strict experimental -ac 6 -ab 384000  -f segment -max_delay 5000000 -avoid_negative_ts disabled -start_at_zero -segment_time 3  -individual_header_trailer 0 -segment_format mpegts -segment_list_type m3u8 -segment_start_number 0 -segment_list "/var/lib/emby-server/transcoding-temp/a3edc1669861b141cc2b8f648ccffd5d.m3u8" -y "/var/lib/emby-server/transcoding-temp/a3edc1669861b141cc2b8f648ccffd5d%d.ts"ffmpeg version N-83152-gf7e9275f83-static http://johnvansickle.com/ffmpeg/  Copyright (c) 2000-2017 the FFmpeg developers  built with gcc 5.4.1 (Debian 5.4.1-4) 20161202  configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio --cc=gcc-5 --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gray --enable-libass --enable-libfreetype --enable-libfribidi --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libzimg  libavutil      55. 43.100 / 55. 43.100  libavcodec     57. 74.100 / 57. 74.100  libavformat    57. 62.100 / 57. 62.100  libavdevice    57.  2.100 / 57.  2.100  libavfilter     6. 69.100 /  6. 69.100  libswscale      4.  3.101 /  4.  3.101  libswresample   2.  4.100 /  2.  4.100  libpostproc    54.  2.100 / 54.  2.100[AVHWDeviceContext @ 0x5000440] No VA display found for device: /dev/dri/renderD128.[vaapi @ 0x30f21e0] Failed to create a VAAPI device
Edited by fkp
Link to comment
Share on other sites

mastrmind11

Looks like VAAPI is correctly installed.  What is the output of ls -al /dev/dri ?  Perhaps you're just selecting an invalid dri.  Try a different one.

Link to comment
Share on other sites

Seems normal :

ls -l /dev/dri
total 0
crw-rw---- 1 root video 226,   0 juil. 15 09:12 card0
crw-rw---- 1 root video 226,  64 juil. 15 09:12 controlD64
crw-rw---- 1 root video 226, 128 juil. 15 09:12 renderD128
 

emby is part of group video.

Link to comment
Share on other sites

Guest plexman

What is your hardware? In my case with i5-6600 I get:

 

libva info: VA-API version 0.39.4

vainfo: Driver version: Intel i965 driver for Intel® Skylake - 1.7.1

 

Enviado desde mi Aquaris E5 mediante Tapatalk

Link to comment
Share on other sites

mastrmind11

I can confirm it's working on Haswell as well.

 

libva info: VA-API version 0.39.4
libva info: va_getDriverName() returns 0
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/i965_drv_video.so
libva info: Found init function __vaDriverInit_0_39
libva info: va_openDriver() returns 0
vainfo: VA-API version: 0.39 (libva 1.7.3)
vainfo: Driver version: Intel i965 driver for Intel® Haswell Server - 1.7.0
  • Like 1
Link to comment
Share on other sites

Guest plexman

Well my last suggestion is to try it under ubuntu 16.04, maybe as ubuntu includes more edgy software than debian it will work.

 

Edit: I understand that it is not an easy solution, but I can't give you more help as it's difficult to know how is your system installed and all your system configuration. Plus, I don't have experience with Debian and VAAPI

 

Enviado desde mi Aquaris E5 mediante Tapatalk

Edited by plexman
Link to comment
Share on other sites

sualfred

johnvansickle version has no VAAPI support. 

 

I've uploaded my compiled static libraries with enabled VAAPI support. There is also a .deb package for installation via dpkg.
https://1drv.ms/f/s!Aj8g8aA7CEOwgfEQ0ykOaAfdomWc9Q

 

Build in the mid of June and based on the GitHub snapshot with this configuration:

 

 

configuration:

    --prefix=/root/sffmpeg/build
    --datadir=/root/sffmpeg/build/etc
    --disable-shared
    --enable-static
    --enable-gpl
    --enable-version3
    --enable-nonfree
    --disable-doc
    --disable-debug
    --disable-ffplay
    --disable-ffserver
    --disable-outdevs
    --enable-runtime-cpudetect
    --extra-cflags='-I/root/sffmpeg/build/include
    --static'
    --extra-ldflags=-L/root/sffmpeg/build/lib
    --extra-libs='-lstdc++ -lexpat -ldl'
    --enable-libopencore-amrnb
    --enable-libopencore-amrwb
    --enable-libfdk-aac
    --enable-libmp3lame
    --enable-libspeex
    --enable-libtheora
    --enable-libvorbis
    --enable-libx264
    --enable-libx265
    --enable-libxvid
    --enable-libvpx
    --enable-libopus
    --enable-librtmp
    --enable-libfreetype
    --enable-libass
    --enable-vaapi
 
Edited by sualfred
  • Like 1
Link to comment
Share on other sites

Not the same error message, but same result with your version of ffmpeg

 

BUT with your version, I've seen a different error message (libva info: Trying to open /usr/lib64/dri/i965_drv_video.so)

so even after updating from Jessie to stretch, my old libs created during my QSV tries were still here in /usr/lib64 and used by the system prior the "system" ones.

 

removed this directory and now it works :D, tested with intel_gpu_top

I have to clean up a little bit my system

 

Thank You Sualfred and all of you.

 

 

ffmpeg -hwaccel vaapi -hwaccel_output_format vaapi -vaapi_device /dev/dri/renderD128 -i file:"/video/movie.mkv" -map_metadata -1 -map_chapters -1 -threads 0 -map 0:0 -map 0:1 -map -0:s -codec:v:0 h264_vaapi  -b:v 3616000 -maxrate 3616000 -bufsize 7232000 -level 41 -force_key_frames "expr:gte(t,n_forced*3)" -vf "format=nv12|vaapi,hwupload" -copyts -vsync -1 -codec:a:0 aac -strict experimental -ac 6 -ab 384000  -f segment -max_delay 5000000 -avoid_negative_ts disabled -start_at_zero -segment_time 3  -individual_header_trailer 0 -segment_format mpegts -segment_list_type m3u8 -segment_start_number 0 -segment_list "/var/lib/emby-server/transcoding-temp/9bb79820349de4fe1669690d5575f372.m3u8" -y "/var/lib/emby-server/transcoding-temp/9bb79820349de4fe1669690d5575f372%d.ts"ffmpeg version N-86486-g752dd19 Copyright (c) 2000-2017 the FFmpeg developers  built with gcc 4.9.2 (Debian 4.9.2-10)  configuration: --prefix=/root/sffmpeg/build --datadir=/root/sffmpeg/build/etc --disable-shared --enable-static --enable-gpl --enable-version3 --enable-nonfree --disable-doc --disable-debug --disable-ffplay --disable-ffserver --disable-outdevs --enable-runtime-cpudetect --extra-cflags='-I/root/sffmpeg/build/include --static' --extra-ldflags=-L/root/sffmpeg/build/lib --extra-libs='-lstdc++ -lexpat -ldl' --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libfdk-aac --enable-libmp3lame --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libx265 --enable-libxvid --enable-libvpx --enable-libopus --enable-librtmp --enable-libfreetype --enable-libass --enable-vaapi  libavutil      55. 66.100 / 55. 66.100  libavcodec     57. 99.100 / 57. 99.100  libavformat    57. 73.100 / 57. 73.100  libavdevice    57.  7.100 / 57.  7.100  libavfilter     6. 92.100 /  6. 92.100  libswscale      4.  7.101 /  4.  7.101  libswresample   2.  8.100 /  2.  8.100  libpostproc    54.  6.100 / 54.  6.100libva info: VA-API version 0.99.0libva info: va_getDriverName() returns 0libva info: Trying to open /usr/lib64/dri/i965_drv_video.solibva info: va_openDriver() returns -1[AVHWDeviceContext @ 0x3789360] Failed to initialise VAAPI connection: -1 (unknown libva error).Device creation failed: -5.Failed to set value '/dev/dri/renderD128' for option 'vaapi_device': Input/output errorError parsing global options: Input/output error
Link to comment
Share on other sites

sualfred

 

 

libva info: User requested driver 'iHD'

libva info: Trying to open /opt/intel/mediasdk/lib64/iHD_drv_video.so

 

Haven't noticed that the QSV driver was still loaded as default, sorry.

 

But nevermind.. glad that I could help. 

 

Btw: If you are facing artefacts -> add the unstable repo of Debian (SID). There is the upcoming 1.8.3 i965-va-driver available. It has a high quality improvment included. Don't forget you have to update vainfo aswell.

Link to comment
Share on other sites

 

Btw: If you are facing artefacts -> add the unstable repo of Debian (SID). There is the upcoming 1.8.3 i965-va-driver available. It has a high quality improvment included. Don't forget you have to update vainfo aswell.

 

 

Thanks for the tip, I've done this update, difficult to see the difference, software transcoding remains better than vaapi.

Edited by fkp
Link to comment
Share on other sites

Guest plexman

[Out of thread] @@fkp the intel vaapi driver came by default with Debian 9 or you had to install something? Because I'm considering jumping from Ubuntu 16.04 to Debian 9 to try it.

Link to comment
Share on other sites

Well, as I have upgraded from Debian 8 to 9, and as it was already installed, I had nothing to do.

I don't know if you install it from scratch, it will be installed, anyway it is very easy to install ( 3 packages ...)

Link to comment
Share on other sites

  • 1 year later...
alfons27

I was in a similar situation as as @@fkp above. My errors looked like this:

[AVHWDeviceContext @ 0x55a2e01f6780] Failed to initialise VAAPI connection: -1 (unknown libva error).
Device creation failed: -5.
Failed to set value '/dev/dri/renderD128' for option 'vaapi_device': Input/output error
Error parsing global options: Input/output error

Apparently emby did not have proper access to the hardware resources (because hardware acceleration worked as a regular user.

It turned out I could mitigate this issue by adding

LIBVA_DRIVERS_PATH=/usr/lib/dri
LIBVA_DRIVER_NAME=iHD

to the file 

/etc/conf.d/emby-server

Maybe this is of help to someone.

 

 

PS: I'm using emby Version 3.5.3.0, running on an Arch Linux machine (Kernel 4.19.8) with Intel Celeron CPU G3930 (w/ integrated Intel HD Graphics 610, Kaby Lake)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...