Jump to content

Hardware encoding on Ubuntu Server


szimat
 Share

Recommended Posts

@@szimat

 

Support for VAAPI was added in ffmpeg 3.1, as far as I am aware of. This version is *very* new. It is neither available in Ubuntu 16.04 nor in Ubuntu 16.10 beta.

 

I think packages will become available soon in https://launchpad.net/~mc3man/+ppa-packages

 

Another option would be compiling it yourself.

 

Personally, I use Debian and packages from deb-multimedia at the moment.

 

I also tried to generate more reproducable results, so I downloaded Big Buck Bunny converted it into an mkv without any audio tracks by using

ffmpeg -i /tmp/bbb_sunflower_1080p_30fps_normal.mp4 -vcodec copy -an out.mkv

 and then I converted the result by using the following commands:

 

The results I obained are:

# Fast transcode, quality 20, bandwidth does not matter: ~102 fps, 14MBit/s
/usr/bin/ffmpeg -hwaccel vaapi -hwaccel_output_format vaapi -vaapi_device /dev/dri/renderD128 \
  -i /tmp/out.mkv -map 0:0 -vf 'format=nv12|vaapi,hwupload' -codec:v:0 h264_vaapi \
  -quality 2 -qp 20 -level 42 -map_metadata -1 -threads 0 -y "/tmp/transcoded.h264"

# Slow transcode, quality 20, bandwidth does matter: ~76 fps, ~8.4MBit/s
/usr/bin/ffmpeg -hwaccel vaapi -hwaccel_output_format vaapi -vaapi_device /dev/dri/renderD128 \
  -i /tmp/out.mkv -map 0:0 -vf 'format=nv12|vaapi,hwupload' -codec:v:0 h264_vaapi \
  -quality 0 -qp 20 -level 42 -map_metadata -1 -threads 0 -y "/tmp/transcoded.h264"

# Bitrate limited transcode: 58 fps, ~4MBit/s
/usr/bin/ffmpeg -hwaccel vaapi -hwaccel_output_format vaapi -vaapi_device /dev/dri/renderD128 \
  -i /tmp/out.mkv -map 0:0 -vf 'format=nv12|vaapi,hwupload' -codec:v:0 h264_vaapi -b 4000k \
  -level 42 -map_metadata -1 -threads 0 -y "/tmp/transcoded.h264"

# Bitrate limited 720p-downsampling transcode: 104 fps, ~3MBit/s
/usr/bin/ffmpeg -hwaccel vaapi -hwaccel_output_format vaapi -vaapi_device /dev/dri/renderD128 \
  -i /tmp/out.mkv -map 0:0 -vf 'format=nv12|vaapi,hwupload,scale_vaapi=w=1280:h=720' \
  -codec:v:0 h264_vaapi -b 3000k -level 42 -map_metadata -1 -threads 0 -y "/tmp/transcoded.h264"

I think that the last two cases resemble how emby uses ffmpeg for transcoding. So my hardware should be capable of transcoding two streams at the same time, especially if one of them is down-sampled to 720p.

Edited by marmayr
  • Like 1
Link to comment
Share on other sites

In the meantime, this site has static builds:

 

http://johnvansickle.com/ffmpeg/

 

You can download that to a folder of your choice, then customize it in the emby server dashboard under Playback -> Transcoding.

Yes, I tried, but to me it looks that vaapi is not enabled on this static build, or I am missing something? I think I will need to build ffmpeg to have vaapi enabled as marmayr said.

 

Sent from my Xperia Z3 Compact using Tapatalk

Edited by szimat
Link to comment
Share on other sites

I'm not sure, I figured it was worth suggesting. You might want to send him a note and ask him to add it. A community member did that previously with quicksync and he obliged.

Link to comment
Share on other sites

@@szimat

 

What does

ffmpeg -encoders 2>/dev/null | grep vaapi

return? Does it list the VA-API encoders? For example:

 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)

In case the VA-API encoders are included, you are probably missing something else. Did you install the libva package and drivers? For example, when using the i965 (intel graphics) driver, you'll have to install the i965-va-driver package. For other hardware, you may have to install other *-va-driver packages.

Edited by marmayr
Link to comment
Share on other sites

I'm not sure, I figured it was worth suggesting. You might want to send him a note and ask him to add it. A community member did that previously with quicksync and he obliged.

 

I think it is not included. I will send him a note and see what will the reply be. I'll keep you updated here.

 

EDIT: emailed John, and ask him to include vaapi in his ffmpeg builds. Hope he will accept it.

 

 

@@szimat

 

What does

ffmpeg -encoders 2>/dev/null | grep vaapi

return? Does it list the VA-API encoders? For example:

 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)

In case the VA-API encoders are included, you are probably missing something else. Did you install the libva package and drivers? For example, when using the i965 (intel graphics) driver, you'll have to install the i965-va-driver package. For other hardware, you may have to install other *-va-driver packages.

 

Doesn't return anything, so it is missing vaapi.

I do have hopefully everything else installed, however

~$ vainfo

Gives me:

error: can't connect to X server!
libva info: VA-API version 0.39.2
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.1)
vainfo: Driver version: Intel i965 driver for Intel(R) CherryView - 1.7.1
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          : VAEntrypointEncSlice
      VAProfileHEVCMain               : VAEntrypointVLD

Not sure if the error that it can't connect to X server is a problem, since for ffmpeg encoding I think no X is required at all, just libva1 vainfo i965-va-driver libva-driver-intel

Edited by szimat
Link to comment
Share on other sites

Good evening,

i updated ubuntu 14.04 to 16.04 because of missing support for my g4500 and installed emby, current 3.0.6200.0.

After testing streaming i saw emby using the ffmpeg in /usr/bin and this was missing qsv and vaapi, so i compiled a ffmpeg 3.1.2 myself with the needed support.

But now when i select quick sync or vaapi in emby webinterface i cant stream any video, only with transcoding off it works.

Is there something missing?

I did a test which has been succesful.

root@Oli-KodiBuntu:~# /usr/bin/ffmpeg -hwaccel vaapi -hwaccel_output_format vaapi -vaapi_device /dev/dri/renderD128 -i out.mkv -map 0:0 -vf 'format=nv12|vaapi,hwupload' -codec:v:0 h264_vaapi -quality 2 -qp 20 -level 42 -map_metadata -1 -threads 0 -y "/root/transcoded.h264"
ffmpeg version 3.1.2-1ubuntu2 Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.2) 20160609
  configuration: --prefix=/usr --extra-version=1ubuntu2 --build-suffix=-ffmpeg --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --cc=cc --cxx=g++ --enable-gpl --disable-stripping --disable-decoder=libopenjpeg --disable-decoder=libschroedinger --enable-avresample --enable-avisynth --enable-gnutls --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzvbi --enable-openal --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libzmq --enable-frei0r --enable-libx264 --enable-libopencv --enable-libmfx --enable-vaapi
  libavutil      55. 28.100 / 55. 28.100
  libavcodec     57. 48.101 / 57. 48.101
  libavformat    57. 41.100 / 57. 41.100
  libavdevice    57.  0.101 / 57.  0.101
  libavfilter     6. 47.100 /  6. 47.100
  libavresample   3.  0.  0 /  3.  0.  0
  libswscale      4.  1.100 /  4.  1.100
  libswresample   2.  1.100 /  2.  1.100
  libpostproc    54.  0.100 / 54.  0.100
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
Input #0, matroska,webm, from 'out.mkv':
  Metadata:
    title           : Big Buck Bunny, Sunflower version
    GENRE           : Animation
    MAJOR_BRAND     : isom
    MINOR_VERSION   : 1
    COMPATIBLE_BRANDS: isomavc1
    COMPOSER        : Sacha Goedegebure
    ARTIST          : Blender Foundation 2008, Janus Bager Kristensen 2013
    COMMENT         : Creative Commons Attribution 3.0 - http://bbb3d.renderfarming.net
    ENCODER         : Lavf57.41.100
  Duration: 00:10:34.60, start: 0.067000, bitrate: 3000 kb/s
    Stream #0:0: Video: h264 (High), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 30 fps, 30 tbr, 1k tbn, 60 tbc (default)
    Metadata:
      HANDLER_NAME    : GPAC ISO Video Handler
      DURATION        : 00:10:34.600000000
[h264 @ 0x38efa20] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.
Output #0, h264, to '/root/transcoded.h264':
  Metadata:
    encoder         : Lavf57.41.100
    Stream #0:0: Video: h264 (h264_vaapi) (High), vaapi_vld, 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 30 fps, 30 tbn, 30 tbc (default)
    Metadata:
      encoder         : Lavc57.48.101 h264_vaapi
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> h264 (h264_vaapi))
Press [q] to stop, [?] for help
[h264 @ 0x39700a0] Hardware accelerated decoding with frame threading is known to be unstable and its use is discouraged.
Input stream #0:0 frame changed from size:1920x1080 fmt:yuv420p to size:1920x1080 fmt:vaapi_vld
frame=19036 fps=161 q=-0.0 Lsize= 1082981kB time=00:10:34.50 bitrate=13982.3kbits/s speed=5.37x    
video:1082981kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.000000%
Link to comment
Share on other sites

What for a level? Are you sure that my ffmpeg is the problem? Transcoding is fine here with 161 fps, so i dont think its reverting to software mode.

Where i can see the command call from emby which starts ffmpeg transcoding?

Link to comment
Share on other sites

But now when i select quick sync or vaapi in emby webinterface i cant stream any video, only with transcoding off it works.

Maybe it depends on the browser? I successfully tested it with Google Chrome (and Chromium). I also successfully tested the Android app and Kodi. Do you get any error messages when opening the browser console?

 

Where i can see the command call from emby which starts ffmpeg transcoding?

In the transcode logs.

~emby/logs/transcode*

You have to find the right one, of course.

Edited by marmayr
Link to comment
Share on other sites

You have level 42 in your command line. Read the link I gave you

Whats the problem with MY command line? I need to get Emby's transcoding work.

I think you don't understand me... If i enable quick sync or vaapi transcoding in Emby i can't play videos anymore.

Transcoding via commandline is working fine.

 

Maybe it depends on the browser? I successfully tested it with Google Chrome (and Chromium). I also successfully tested the Android app and Kodi. Do you get any error messages when opening the browser console?

 

In the transcode logs.

~emby/logs/transcode*

You have to find the right one, of course.

I don't think its a browser problem, the settings get saved because when i set to off the video playback is working again.

 

Edit:

Ok thats funny (maybe not)

2016-08-27 00:34:19.2246 Info App: /usr/bin/ffmpeg -fflags +genpts -hwaccel vaapi -hwaccel_output_format vaapi -vaapi_device /dev/dri/card0 -i file:"/home/oli/NAS/sdb/1--- Bilder ---1/Cabanossi & Friends/2013/05 Mai/09.05.2013 Herrentags Chaos/00009.MTS" -ss 00:00:01.000 -map 0:0 -map 0:1 -map -0:s -codec:v:0 h264_vaapi -force_key_frames "expr:gte(t,n_forced*5)" -vf "format=nv12|vaapi,hwupload" -b:v 3744002 -maxrate 3744002 -bufsize 7488004 -vsync -1 -level 41 -map_metadata -1 -threads 0 -codec:a:0 copy -y "/home/oli/NAS/sdb/Logs/transcoding-temp/a87f392005da4fb2cef2914b38441a11.mkv"
2016-08-27 00:34:19.3510 Info App: FFMpeg exited with code 1

ffmpeg exits when its starts by Emby, but when i run the command manually, it works!

root@Oli-KodiBuntu:~# /usr/bin/ffmpeg -fflags +genpts -hwaccel vaapi -hwaccel_output_format vaapi -vaapi_device /dev/dri/card0 -i file:"/home/oli/NAS/sdb/1--- Bilder ---1/Cabanossi & Friends/2013/05 Mai/09.05.2013 Herrentags Chaos/00009.MTS" -ss 00:00:01.000 -map 0:0 -map 0:1 -map -0:s -codec:v:0 h264_vaapi -force_key_frames "expr:gte(t,n_forced*5)" -vf "format=nv12|vaapi,hwupload" -b:v 3744002 -maxrate 3744002 -bufsize 7488004 -vsync -1 -level 41 -map_metadata -1 -threads 0 -codec:a:0 copy -y "/home/oli/NAS/sdb/Logs/transcoding-temp/a87f392005da4fb2cef2914b38441a11.mkv"
ffmpeg version 3.1.2-1ubuntu2 Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.2) 20160609
  configuration: --prefix=/usr --extra-version=1ubuntu2 --build-suffix=-ffmpeg --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --cc=cc --cxx=g++ --enable-gpl --disable-stripping --disable-decoder=libopenjpeg --disable-decoder=libschroedinger --enable-avresample --enable-avisynth --enable-gnutls --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzvbi --enable-openal --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libzmq --enable-frei0r --enable-libx264 --enable-libopencv --enable-libmfx --enable-vaapi
  libavutil      55. 28.100 / 55. 28.100
  libavcodec     57. 48.101 / 57. 48.101
  libavformat    57. 41.100 / 57. 41.100
  libavdevice    57.  0.101 / 57.  0.101
  libavfilter     6. 47.100 /  6. 47.100
  libavresample   3.  0.  0 /  3.  0.  0
  libswscale      4.  1.100 /  4.  1.100
  libswresample   2.  1.100 /  2.  1.100
  libpostproc    54.  0.100 / 54.  0.100
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
Input #0, mpegts, from 'file:/home/oli/NAS/sdb/1--- Bilder ---1/Cabanossi & Friends/2013/05 Mai/09.05.2013 Herrentags Chaos/00009.MTS':
  Duration: 00:04:07.01, start: 1.040000, bitrate: 22468 kb/s
  Program 1 
    Stream #0:0[0x1011]: Video: h264 (High) (HDMV / 0x564D4448), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 25 fps, 25 tbr, 90k tbn, 50 tbc
    Stream #0:1[0x1100]: Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, stereo, fltp, 256 kb/s
    Stream #0:2[0x1200]: Subtitle: hdmv_pgs_subtitle ([144][0][0][0] / 0x0090), 1920x1080
[matroska @ 0x3a014c0] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.
    Last message repeated 1 times
Output #0, matroska, to '/home/oli/NAS/sdb/Logs/transcoding-temp/a87f392005da4fb2cef2914b38441a11.mkv':
  Metadata:
    encoder         : Lavf57.41.100
    Stream #0:0: Video: h264 (h264_vaapi) (High) (H264 / 0x34363248), vaapi_vld, 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 3744 kb/s, 25 fps, 1k tbn, 25 tbc
    Metadata:
      encoder         : Lavc57.48.101 h264_vaapi
    Stream #0:1: Audio: ac3 ([0] [0][0] / 0x2000), 48000 Hz, stereo, 256 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> h264 (h264_vaapi))
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
[h264 @ 0x3a6b240] Hardware accelerated decoding with frame threading is known to be unstable and its use is discouraged.
Input stream #0:0 frame changed from size:1920x1080 fmt:yuv420p to size:1920x1080 fmt:vaapi_vld
frame= 6150 fps=126 q=-0.0 Lsize=  120059kB time=00:04:06.00 bitrate=3997.9kbits/s speed=5.03x    
video:112272kB audio:7792kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown

Edit2:

vaapi seems to need root. I tried the commandline from Emby under another user and it does'nt work too.

Only root can do it.

Is there a solution to only give ffmpeg root and not the whole Emby server?

Thanks :)

Edited by Wired Life
Link to comment
Share on other sites

Nevermind, your log suggested to me that it was outside of Emby you were testing. Maybe you can take the Emby command line and change the level from 42 to 41 and run it standalone and see what happens.

Link to comment
Share on other sites

Oh man... are you reading my posts?

I did everything but now i'm out of ideas...

I added the emby user to the video group because Emby need permissions to /dev/dri.

Now i can execute the command from the server.txt which fails with "sudo -u emby" as emby user and it works, but still nothing with emby server...

2016-08-27 04:41:04.4403 Info App: /usr/bin/ffmpeg -fflags +genpts -hwaccel vaapi -hwaccel_output_format vaapi -vaapi_device /dev/dri/renderD128 -i file:"/home/oli/NAS/sdb/1--- Bilder ---1/Cabanossi & Friends/2013/05 Mai/09.05.2013 Herrentags Chaos/00010.MTS" -ss 00:00:01.000 -map 0:0 -map 0:1 -map -0:s -codec:v:0 h264_vaapi -force_key_frames "expr:gte(t,n_forced*5)" -vf "format=nv12|vaapi,hwupload" -b:v 3744002 -maxrate 3744002 -bufsize 7488004 -vsync -1 -level 41 -map_metadata -1 -threads 0 -codec:a:0 copy -y "/home/oli/NAS/sdb/Logs/transcoding-temp/985f0405639db312589124b891a4b2f6.mkv"
2016-08-27 04:41:04.4850 Info App: FFMpeg exited with code 1

root@Oli-KodiBuntu:/var/lib/emby-server/logs# sudo -u emby /usr/bin/ffmpeg -fflags +genpts -hwaccel vaapi -hwaccel_output_format vaapi -vaapi_device /dev/dri/renderD128 -i file:"/home/oli/NAS/sdb/1--- Bilder ---1/Cabanossi & Friends/2013/05 Mai/09.05.2013 Herrentags Chaos/00010.MTS" -ss 00:00:01.000 -map 0:0 -map 0:1 -map -0:s -codec:v:0 h264_vaapi -force_key_frames "expr:gte(t,n_forced*5)" -vf "format=nv12|vaapi,hwupload" -b:v 3744002 -maxrate 3744002 -bufsize 7488004 -vsync -1 -level 41 -map_metadata -1 -threads 0 -codec:a:0 copy -y "/home/oli/NAS/sdb/Logs/transcoding-temp/985f0405639db312589124b891a4b2f6.mkv"
ffmpeg version 3.1.2 Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.2) 20160609
  configuration: --prefix=/usr --disable-debug --disable-shared --disable-stripping --enable-avfilter --enable-avisynth --enable-avresample --enable-bzlib --enable-frei0r --enable-gnutls --enable-gpl --enable-nonfree --enable-openal --enable-opengl --enable-postproc --enable-pthreads --enable-runtime-cpudetect --enable-swscale --enable-vaapi --enable-vdpau --enable-version3 --enable-x11grab --enable-zlib --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libdc1394 --enable-libfaac --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmfx --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopencv --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvo-amrwbenc --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libzmq --enable-libzvbi
  libavutil      55. 28.100 / 55. 28.100
  libavcodec     57. 48.101 / 57. 48.101
  libavformat    57. 41.100 / 57. 41.100
  libavdevice    57.  0.101 / 57.  0.101
  libavfilter     6. 47.100 /  6. 47.100
  libavresample   3.  0.  0 /  3.  0.  0
  libswscale      4.  1.100 /  4.  1.100
  libswresample   2.  1.100 /  2.  1.100
  libpostproc    54.  0.100 / 54.  0.100
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
Input #0, mpegts, from 'file:/home/oli/NAS/sdb/1--- Bilder ---1/Cabanossi & Friends/2013/05 Mai/09.05.2013 Herrentags Chaos/00010.MTS':
  Duration: 00:03:13.98, start: 1.040000, bitrate: 22480 kb/s
  Program 1 
    Stream #0:0[0x1011]: Video: h264 (High) (HDMV / 0x564D4448), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 25 fps, 25 tbr, 90k tbn, 50 tbc
    Stream #0:1[0x1100]: Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, stereo, fltp, 256 kb/s
    Stream #0:2[0x1200]: Subtitle: hdmv_pgs_subtitle ([144][0][0][0] / 0x0090), 1920x1080
[matroska @ 0x36cd4e0] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.
    Last message repeated 1 times
Output #0, matroska, to '/home/oli/NAS/sdb/Logs/transcoding-temp/985f0405639db312589124b891a4b2f6.mkv':
  Metadata:
    encoder         : Lavf57.41.100
    Stream #0:0: Video: h264 (h264_vaapi) (High) (H264 / 0x34363248), vaapi_vld, 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 3744 kb/s, 25 fps, 1k tbn, 25 tbc
    Metadata:
      encoder         : Lavc57.48.101 h264_vaapi
    Stream #0:1: Audio: ac3 ([0] [0][0] / 0x2000), 48000 Hz, stereo, 256 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> h264 (h264_vaapi))
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
[h264 @ 0x3737260] Hardware accelerated decoding with frame threading is known to be unstable and its use is discouraged.
Input stream #0:0 frame changed from size:1920x1080 fmt:yuv420p to size:1920x1080 fmt:vaapi_vld
frame= 4824 fps=125 q=-0.0 Lsize=   94341kB time=00:03:12.98 bitrate=4004.7kbits/s speed=4.99x    
video:88232kB audio:6112kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Edited by Wired Life
Link to comment
Share on other sites

I am reading your posts but what I'm paying the most attention to are the warning messages in the ffmpeg log.

Link to comment
Share on other sites

I don't think its a browser problem, the settings get saved because when i set to off the video playback is working again.

Did you try it out with one of the browsers I tested? Did you take a look at the browser log?

 

If the browser has errors during play back, then ffmpeg will exit. There is a chance that the VAApi stream differs in a way from the non-VAApi stream and that the browser can't handle it.

Link to comment
Share on other sites

I tried with the Android App with and without the internal Player, Firefox and Chrome.

The Problem is in the way which Emby starts ffmpeg.

When you read my posts you see it works when i start the command from Embys server.txt manually.

Link to comment
Share on other sites

Now i found the problem!

Emby cant handle spaces in the directory path! I added some content without spaces in the path and it works!

Link to comment
Share on other sites

I see... the spaces are not the problem, maybe the - or & signs in my path?

Currently i make a test with & in path, when this works i add the -

Link to comment
Share on other sites

If it is related to file names, I'd try quotation marks ("') and dollar ($) signs and backticks (`). I can't think of other characters that may break stuff at the moment

 

Or is it related to particular files? In that case, you should share as much information about those as possible (in particular codecs).

Link to comment
Share on other sites

Think it was a problem with my database, i deleted it and tested a single folder and it works, but the video quality on transcoding is sooo bad, pixels over pixels.

Has anyone got vaapi transcoding running with good video quality?

Link to comment
Share on other sites

Hi,

 

I also got the "artefact-issue" with vaapi, so I tested how it is without vaapi with a powerful cpu

 

And there is a huge difference

 

this is on i7 without vaapi

 

frame=  409 fps=116 q=22.0 size=   10049kB time=00:55:47.98 bitrate=  24.6kbits/s speed= 949x

frame=  456 fps=113 q=22.0 size=   11528kB time=00:55:49.88 bitrate=  28.2kbits/s speed= 831x

frame=  512 fps=113 q=24.0 size=   13099kB time=00:55:52.18 bitrate=  32.0kbits/s speed= 738x

frame=  573 fps=114 q=25.0 size=   14383kB time=00:55:54.75 bitrate=  35.1kbits/s speed= 665x

frame=  631 fps=114 q=21.0 size=   15433kB time=00:55:57.22 bitrate=  37.7kbits/s speed= 605x

frame=  694 fps=115 q=24.0 size=   16673kB time=00:55:59.86 bitrate=  40.7kbits/s speed= 555x

frame=  757 fps=116 q=24.0 size=   17944kB time=00:56:02.45 bitrate=  43.7kbits/s speed= 513x

 

 

and this on a n3700 with vaapi

frame=  781 fps= 85 q=-0.0 size=    9805kB time=00:00:32.68 bitrate=2457.2kbits/s speed=3.55x

frame=  825 fps= 85 q=-0.0 size=   10480kB time=00:00:34.51 bitrate=2487.6kbits/s speed=3.55x

frame=  861 fps= 84 q=-0.0 size=   10908kB time=00:00:36.02 bitrate=2480.4kbits/s speed=3.51x

frame=  944 fps= 83 q=-0.0 size=   11087kB time=00:00:39.52 bitrate=2297.8kbits/s speed=3.49x 

frame=  983 fps= 83 q=-0.0 size=   11189kB time=00:00:41.13 bitrate=2228.1kbits/s speed=3.48x

frame= 1024 fps= 83 q=-0.0 size=   11268kB time=00:00:42.88 bitrate=2152.2kbits/s speed=3.48x

frame= 1062 fps= 83 q=-0.0 size=   11345kB time=00:00:44.54 bitrate=2086.4kbits/s speed=3.47x

frame= 1102 fps= 83 q=-0.0 size=   11429kB time=00:00:46.05 bitrate=2032.8kbits/s speed=3.45x

frame= 1142 fps= 82 q=-0.0 size=   11508kB time=00:00:47.80 bitrate=1971.9kbits/s speed=3.45x

frame= 1180 fps= 82 q=-0.0 size=   11578kB time=00:00:49.41 bitrate=1919.3kbits/s speed=3.44x 

 

the i 7 is without artefacts smooth, but of course heavy load.

 

I am not that familiar with these values, but it would be nice if someone could paste some of a quicksync enabled ffmpeg

 

Because I dont wanna mess around for hours anymore with quicksync and linux if it will not give me any benefit

Thx in advance

Link to comment
Share on other sites

QuickSync and VA-API should be comparable (at least in the long run), because those are different APIs for the same hardware (when using an Intel processor). There may be differences in the current ffmpeg implementation, but if there are any, I expect them to vanish for must use cases.

 

When using hardware acceleration, you are always trading either bandwidth or quality for speed/efficiency. If quality is too bad, you have to provide more bandwidth. If this is not an option, you have to use non-hardware accelerated transcoding, but you may need a stronger processor then.

 

You seem to encode at about 2MBit (without a fixed quality rate). Depending on the resolution, quality may be *very* bad. Using the following command, you should get a similar quality (most of the time) using VA-API:

/usr/bin/ffmpeg -hwaccel vaapi -hwaccel_output_format vaapi -vaapi_device /dev/dri/renderD128 \
-i /tmp/out.mkv -map 0:0 -vf 'format=nv12|vaapi,hwupload' -codec:v:0 h264_vaapi \
-quality 0 -qp 22 -level 42 -map_metadata -1 -threads 0 -y "/tmp/transcoded.h264"

My use cases for hardware transcoding are:

 

1.) When a device in the local-area network does not support the H264 profile I use for encoding, I use transcoding. Bandwidth is pretty much unconstrained and quality is (almost) as good as in the original.

2.) When I am on the go and want to watch something, I tend to transcode to 720p @ 3MBit or 480p at a lower bitrate. Quality is reasonable then. Sometimes it drops a bit, but I can live with it.

Link to comment
Share on other sites

Hi, thx for your answer, really appreciated

 

good part is, I dont have to figure out quicksync anymore ;)

 

The above command was copied from emby during transcoding  via

"ps axfwwww |grep ffmpeg"

 

 /usr/bin/ffmpeg -fflags +genpts -hwaccel vaapi -hwaccel_output_format vaapi -vaapi_device /dev/dri/card0 -i file:"/mnt/test.mkv" -ss 00:00:01.000 -map 0:0 -map 0:1 -map -0:s -codec:v:0 h264_vaapi -force_key_frames "expr:gte(t,n_forced*5)" -vf "format=nv12|vaapi,hwupload,scale_vaapi=w=1280:h=532" -copyts -avoid_negative_ts disabled -start_at_zero -b:v 2464002 -maxrate 2464002 -bufsize 4928004 -vsync -1 -level 51 -map_metadata -1 -threads 0 -codec:a:0 libmp3lame -ac 2 -ab 1536000 -af "aresample=async=1,volume=2" -y "/tmp/0e92c7a528a973f5212c3023ca229caf.mkv"

 

 

but you are right, with your parameters the result is a lot better but how do you limit bandwith with these parameters?

 

 

how did you configure emby to use different parameters?

 

I mean in your command there is no bandwidth, just quality parameters, so I guess it have will peaks during some scenes, what i guess is pretty fine and a cache of the client should be able to handle that, but as mentioned before, I have no clue how to tell emby, that it should use quality parameters instead of bandwidth

 

Thx and cheers

Edited by schamane
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
 Share

×
×
  • Create New...