[Linux Station] Running Emby with hardware accelerated transcoding in Linux Station

Discussion about various official QPKG software applications. Login required to view the contents.
se_dony
New here
Posts: 8
Joined: Fri May 06, 2016 1:41 am

[Linux Station] Running Emby with hardware accelerated transcoding in Linux Station

Post by se_dony »

Hey there,

After digging around for a couple of days in the Emby forum I have figured something out to get hardware accelerated transcoding working with Emby on my TS-253A. Actually with QTS 4.3 beta almost everything is already in place to get it working.

The main issue is that the static ffmpeg builds on this forum and also all others that I found online do not have VA-API enabled.

I tried to compile a fully static ffmpeg x64 build with VA-API support enabled however there are tons of dependencies and it would have taken ages for me to fulfil al those dependencies and to compile it successfully. If somebody has such a build: It would be great, if you could post it!

However there are dynamic ffmpeg builds that have VA-API enabled. I therefore powered up ubuntu in Linux Station and installed Emby there:

Code: Select all

sudo sh -c "echo 'deb http://download.opensuse.org/repositories/home:/emby/xUbuntu_16.04/ /' >> /etc/apt/sources.list.d/emby-server.list"
sudo apt-get update
sudo apt-get install emby-server
Start Emby with either:

Code: Select all

sudo service emby-server start
or

Code: Select all

sudo /etc/init.d/emby-server start
To get a ffmpeg build with VA-API enabled, install for example the one from the hybrid repo:

Code: Select all

sudo add-apt-repository ppa:djcj/hybrid
sudo apt-get update
sudo app-get install ffmpeg
Check which ffmpeg version is installed:

Code: Select all

sudo apt-cache policy ffmpeg
Check for VA-API in ffmpeg:

Code: Select all

ffmpeg -encoders 2> /dev/null  | grep vaapi
This should give you something like this:

Code: Select all

 V..... h264_vaapi           H.264/AVC (VAAPI) (codec h264)
 V..... hevc_vaapi           H.265/HEVC (VAAPI) (codec hevc)
 V..... mjpeg_vaapi          MJPEG (VAAPI) (codec mjpeg)
You can also do an encoding testrun with:

Code: Select all

ffmpeg -vaapi_device /dev/dri/renderD128 -f lavfi -i nullsrc=s=1280x720 -t 1 -vf 'format=nv12,hwupload' -vcodec h264_vaapi -f null -
Install vainfo to see if VA-API is working in Linux Station

Code: Select all

sudo apt-get install vainfo
Run

Code: Select all

vainfo
This should give you something like:

Code: Select all

libva info: VA-API version 0.39.0
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.0)
vainfo: Driver version: Intel i965 driver for Intel(R) CherryView - 1.7.0
vainfo: Supported profile and entrypoints
      VAProfileMPEG2Simple            : VAEntrypointVLD
      VAProfileMPEG2Simple            : VAEntrypointEncSlice
      VAProfileMPEG2Main              : VAEntrypointVLD
      VAProfileMPEG2Main              : VAEntrypointEncSlice
      VAProfileH264ConstrainedBaseline: VAEntrypointVLD
      VAProfileH264ConstrainedBaseline: VAEntrypointEncSlice
      VAProfileH264Main               : VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointEncSlice
      VAProfileH264High               : VAEntrypointVLD
      VAProfileH264High               : VAEntrypointEncSlice
      VAProfileH264MultiviewHigh      : VAEntrypointVLD
      VAProfileH264MultiviewHigh      : VAEntrypointEncSlice
      VAProfileH264StereoHigh         : VAEntrypointVLD
      VAProfileH264StereoHigh         : VAEntrypointEncSlice
      VAProfileVC1Simple              : VAEntrypointVLD
      VAProfileVC1Main                : VAEntrypointVLD
      VAProfileVC1Advanced            : VAEntrypointVLD
      VAProfileNone                   : VAEntrypointVideoProc
      VAProfileJPEGBaseline           : VAEntrypointVLD
      VAProfileJPEGBaseline           : VAEntrypointEncPicture
      VAProfileVP8Version0_3          : VAEntrypointVLD
      VAProfileVP8Version0_3          : VAEntrypointEncS
Perfect. Now check the rendering devices:

Code: Select all

ls -l /dev/dri/*
This should give you:

Code: Select all

crw-rw----+ 1 root video 226,   0 Feb  5 08:08 /dev/dri/card0
crw-rw----  1 root video 226,  64 Feb  5 08:08 /dev/dri/controlD64
crw-rw----+ 1 root video 226, 128 Feb  5 08:08 /dev/dri/renderD128
We will use the renderD128. You could also use card0, but this is sometimes blocked by X.

Emby is running as the user “emby” on Linux Station, we will have to add the user “emby” to the “video” group to have the right to access renderD128:

Code: Select all

usermod -a -G video emby
We are all set. Now go to your emby server and enable hardware transcoding under “Transcoding” using VA-API and “/dev/dri/renderD128” as the device.

You can check the Emby logs if it is working.

Enjoy!

Daniel
Last edited by se_dony on Wed Feb 08, 2017 4:54 pm, edited 1 time in total.
swiederm
New here
Posts: 5
Joined: Tue Sep 06, 2011 7:50 pm

Re: [Linux Station] Running Emby with hardware accelerated transcoding in Linux Station

Post by swiederm »

Hi Daniel,

Can a similar thing be done with Kodi Krypton on Linux Station?

I managed to get software rendering working, but not video hardware acceleration. Everything else worked great.

regards, Steve
se_dony
New here
Posts: 8
Joined: Fri May 06, 2016 1:41 am

Re: [Linux Station] Running Emby with hardware accelerated transcoding in Linux Station

Post by se_dony »

Should work for Kodi Krypton on Linux Station as VA-API is generally working in Linux Station. Haven't tried yet though. More info here:

http://forum.kodi.tv/showthread.php?tid=231955

Also remember that the user running kodi must belong to the "video" group so that he can access the DRI device.

Best

Daniel
swiederm
New here
Posts: 5
Joined: Tue Sep 06, 2011 7:50 pm

Re: [Linux Station] Running Emby with hardware accelerated transcoding in Linux Station

Post by swiederm »

Cheers,

Yes, added kodi user to video group and had to add group permissions to the shared multimedia folder.

To get the hardware acceleration to work, I had to install some items from ppa:wsnipex/mesa. Otherwise Kodi was displaying audio with black screen and throwing an NV12 error. I'm not sure which part of the package was the fix. I also added the ppa:wsnipex/vaapi, but this wasn't the issue.

EDIT UPDATE. This 'fix' does not survive a reboot - still working on it.

EDIT 2 UPDATE. Solved with installing additional stuff from PPA-team-xbmc/trusty. I selected a few things and one of them worked - vainfo, libva-egl1, libva-dr , libva-x11-1, libva-wayland1.

This is all on ubuntu 14.04 as I can't get my VPN (PIA) to function on 16.

regards, Steve
lowfi
Know my way around
Posts: 112
Joined: Fri Oct 16, 2015 10:49 pm

Re: [Linux Station] Running Emby with hardware accelerated transcoding in Linux Station

Post by lowfi »

Which ffmpeg path should you use in emby?

/usb/bin/ffmpeg?
lowfi
Know my way around
Posts: 112
Joined: Fri Oct 16, 2015 10:49 pm

Re: [Linux Station] Running Emby with hardware accelerated transcoding in Linux Station

Post by lowfi »

Im frequently seeing this in the logs:

[AVHWDeviceContext @ 0x561a99d0b460] No VA display found for device: /dev/dri/card0.

However:

admin@ubuntu_1604:~$ ls -l /dev/dri/*
crw-rw----+ 1 root video 226, 0 三 13 13:06 /dev/dri/card0
crw-rw---- 1 root video 226, 64 三 13 13:06 /dev/dri/controlD64
crw-rw----+ 1 root video 226, 128 三 13 13:06 /dev/dri/renderD128

This is on an intel 4 bays nas (ts453pro)
kayrune
Starting out
Posts: 24
Joined: Mon Mar 16, 2015 3:15 am

Re: [Linux Station] Running Emby with hardware accelerated transcoding in Linux Station

Post by kayrune »

Any updates on a static ffmpeg build, I would much prefer to run this in a container or as a qpkg than to run full ubuntu in Linux station.

Actually the official emby container comes with full va-api support now it seems, unfortunately I cannot get it working. I've set up the container in privileget mode with R/W on DRI

bash-4.4# ls /dev/dri -la
total 0
drwxr-xr-x 2 root root 100 May 6 12:18 .
drwxr-xr-x 14 root root 20580 May 6 12:18 ..
crw------- 1 root root 226, 0 May 6 12:18 card0
crw------- 1 root root 226, 64 May 6 12:18 controlD64
crw------- 1 root root 226, 128 May 6 12:18 renderD128

Unfortunatly it does not work :(

bash-4.4# ffmpeg -vaapi_device /dev/dri/renderD128 -f lavfi -i nullsrc=s=1280x720 -t 1 -vf 'format=nv12,hwupload' -vcodec h264_vaapi -f null -
ffmpeg version N-83692-gb8a7dcbde2-static http://johnvansickle.com/ffmpeg/ Copyright (c) 2000-2017 the FFmpeg developers
built with gcc 5.4.1 (Debian 5.4.1-5) 20170205
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. 47.100 / 55. 47.100
libavcodec 57. 81.100 / 57. 81.100
libavformat 57. 66.102 / 57. 66.102
libavdevice 57. 3.100 / 57. 3.100
libavfilter 6. 74.100 / 6. 74.100
libswscale 4. 3.101 / 4. 3.101
libswresample 2. 4.100 / 2. 4.100
libpostproc 54. 2.100 / 54. 2.100
[AVHWDeviceContext @ 0x510fec0] No VA display found for device: /dev/dri/renderD128.
[vaapi @ 0x312f1e0] Failed to create a VAAPI device
kayrune
Starting out
Posts: 24
Joined: Mon Mar 16, 2015 3:15 am

Re: [Linux Station] Running Emby with hardware accelerated transcoding in Linux Station

Post by kayrune »

I've set this up in Linux Station as described by OP. And it was working perfectly on first try. But then I tried to change encode settings (lower bitrate). And it has failed ever since with the same: [AVHWDeviceContext @ 0x55f942395680] No VA display found for device: /dev/dri/renderD128.
[vaapi @ 0x55f94146a0f0] Failed to create a VAAPI device

I've tried rebooting the Linux station but does not help :(
st167
New here
Posts: 7
Joined: Tue Mar 14, 2017 5:15 am

Re: [Linux Station] Running Emby with hardware accelerated transcoding in Linux Station

Post by st167 »

Any luck with this one?
Has anyone figured out how to enable hardware transcoding when Emby is installed a qpkg...and not in LS ?
Getting same error as others - Failed to create a VAAPI device.

Plex hardware transcoding preview release works fine!

system = TS-251+, Firmware 4.3, Emby 3.2.19
virtualdj
Experience counts
Posts: 2141
Joined: Wed May 26, 2010 2:44 am

Re: [Linux Station] Running Emby with hardware accelerated transcoding in Linux Station

Post by virtualdj »

se_dony wrote:The main issue is that the static ffmpeg builds on this forum and also all others that I found online do not have VA-API enabled.

I tried to compile a fully static ffmpeg x64 build with VA-API support enabled however there are tons of dependencies and it would have taken ages for me to fulfil al those dependencies and to compile it successfully. If somebody has such a build: It would be great, if you could post it!
The new Emby QNAP Testing package available HERE has a version of ffmpeg with vaapi support inside the "bin" folder.
If you extract the QPKG with qbuild then you'll be able to use it even without Emby:

Code: Select all

[/share/Public/test/bin] # LD_LIBRARY_PATH=../lib:../lib/samba ./ffmpeg -encoders | grep vaapi
  ffmpeg version 3.4.1 Copyright (c) 2000-2017 the FFmpeg developers
  built with gcc 6.3.0 (crosstool-NG crosstool-ng-1.23.0)
  configuration: --enable-cross-compile --cross-prefix=x86_64-pc-linux-gnu- --arch=x86_64 --target-os=linux --prefix=/srv/buildbot/x64/ffmpeg-x64/staging --pkg-config=pkg-config --disable-static --disable-cuda --disable-cuvid --disable-iconv --disable-nvenc --disable-doc --disable-ffplay --disable-ffserver --disable-xlib --enable-shared --enable-fontconfig --enable-gnutls --enable-gpl --enable-libass --enable-libfreetype --enable-libfribidi --enable-libmp3lame --enable-libopus --enable-libsmbclient --enable-libtheora --enable-libvorbis --enable-libwebp --enable-libx264 --enable-libzvbi --enable-vaapi --enable-version3 --extra-libs='-laddns-samba4 -lasn1util-samba4 -lauthkrb5-samba4 -lCHARSET3-samba4 -lcliauth-samba4 -lcli-cldap-samba4 -lcli-ldap-common-samba4 -lcli-nbt-samba4 -lcli-smb-common-samba4 -lcom_err -lcommon-auth-samba4 -ldbwrap-samba4 -ldcerpc-binding -ldcerpc-samba-samba4 -ldl -ldrm -lexpat -lflag-mapping-samba4 -lfreetype -lfribidi -lfontconfig -lgenrand-samba4 -lgensec-samba4 -lgmp -lgse-samba4 -lgssapi_krb5 -lhogweed -llibcli-lsa3-samba4 -llibsmb-samba4 -linterfaces-samba4 -liov-buf-samba4 -lk5crypto -lkrb5 -lkrb5samba-samba4 -lkrb5support -lldb -lldbsamba-samba4 -lmessages-dgm-samba4 -lmessages-util-samba4 -lmsghdr-samba4 -lmsrpc3-samba4 -lndr -lndr-krb5pac -lndr-nbt -lndr-samba-samba4 -lndr-standard -lnettle -lpng -lreplace-samba4 -lsamba-cluster-support-samba4 -lsamba-credentials -lsamba-debug-samba4 -lsamba-errors -lsamba-hostconfig -lsamba-modules-samba4 -lsamba-security-samba4 -lsamba-sockets-samba4 -lsamba-util -lsamba3-util-samba4 -lsamdb -lsamdb-common-samba4 -lsecrets3-samba4 -lserver-id-db-samba4 -lserver-role-samba4 -lsmbconf -lsmbd-shim-samba4 -lsmb-transport-samba4 -lsocket-blocking-samba4 -lsys-rw-samba4 -ltalloc -ltalloc-report-samba4 -ltdb -ltdb-wrap-samba4 -ltevent -ltevent-util -ltime-basic-samba4 -lutil-cmdline-samba4 -lutil-reg-samba4 -lutil-setid-samba4 -lutil-tdb-samba4 -lwbclient -lwinbind-client-samba4'
  libavutil      55. 78.100 / 55. 78.100
  libavcodec     57.107.100 / 57.107.100
  libavformat    57. 83.100 / 57. 83.100
  libavdevice    57. 10.100 / 57. 10.100
  libavfilter     6.107.100 /  6.107.100
  libswscale      4.  8.100 /  4.  8.100
  libswresample   2.  9.100 /  2.  9.100
  libpostproc    54.  7.100 / 54.  7.100
 V..... h264_vaapi           H.264/AVC (VAAPI) (codec h264)
 V..... hevc_vaapi           H.265/HEVC (VAAPI) (codec hevc)
 V..... mjpeg_vaapi          MJPEG (VAAPI) (codec mjpeg)
 V..... mpeg2_vaapi          MPEG-2 (VAAPI) (codec mpeg2video)
 V..... vp8_vaapi            VP8 (VAAPI) (codec vp8)
 V..... vp9_vaapi            VP9 (VAAPI) (codec vp9)
Probably they managed to build a complete version of ffmpeg dependencies using cross-compilation. :)
mooturner
Starting out
Posts: 20
Joined: Sat Jun 24, 2017 4:43 pm

Re: [Linux Station] Running Emby with hardware accelerated transcoding in Linux Station

Post by mooturner »

Hi. Sorry to open an old thread.

Can someone explain how to extract this version of ffmpeg? I'd love to be able to transcode video using va_api on my TS253A.

MT
User avatar
nickiman
Know my way around
Posts: 217
Joined: Thu Nov 13, 2014 11:15 pm
Location: Madrid, Spain

Re: [Linux Station] Running Emby with hardware accelerated transcoding in Linux Station

Post by nickiman »

I´m interested also in this... maybe @virtualdj can help us.

If he is still watching this thread... let´s give him some time to reply us... if he doesn´t reply maybe I can call him in other thread.
TS-453 Pro - FW: QTS 5.1.4.2596
6Tb WD Red WD6002FFWX (x4) with RAID 5
User avatar
nickiman
Know my way around
Posts: 217
Joined: Thu Nov 13, 2014 11:15 pm
Location: Madrid, Spain

Re: [Linux Station] Running Emby with hardware accelerated transcoding in Linux Station

Post by nickiman »

We need to install QDK 2.3.1 package in order to use qbuild command. But I haven´t extracted a qpkg before so I don´t know how to do it.
TS-453 Pro - FW: QTS 5.1.4.2596
6Tb WD Red WD6002FFWX (x4) with RAID 5
virtualdj
Experience counts
Posts: 2141
Joined: Wed May 26, 2010 2:44 am

Re: [Linux Station] Running Emby with hardware accelerated transcoding in Linux Station

Post by virtualdj »

Yes, you can install QDK and then you can use the "qbuild --extract qpkg_file" command and you'll get all the files within.
mooturner
Starting out
Posts: 20
Joined: Sat Jun 24, 2017 4:43 pm

Re: [Linux Station] Running Emby with hardware accelerated transcoding in Linux Station

Post by mooturner »

Had a crack. All I got was 4 files:

# qbuild --extract emby-server-qnap_3.4.1.0_x86_64.qpkg
./
./built_info
./qinstall.sh
./package_routines
./qpkg.cfg
Post Reply

Return to “Official Apps”