Jump to content

Hardware encoding on Ubuntu Server


szimat
 Share

Recommended Posts

Some add hoc tests. The last ones are most important, as they check the success of actual encode process. The first two are actually covered by "vainfo", which anybody trying to get vaapi working, should install anyway. Also there are additional encoding capabilities coming all the time with new chips, new vaapi, new ffmpeg... I'n not an expert on this, so there could be smarter ways to do this.

 


 

 

Amending my own post: Looks like there is no easy way to find out hardware _de_coding capabilities of hwaccel/vaapi. It can be done programmatically but not with static version of ffmpeg (AFAIK).

 

BR,

Andy777

Link to comment
Share on other sites

I have been able to get quicksync to work but only on Ubuntu 14.04 and only with the patched kernel.  My cpu is 4th Generation so no deal on the new 2017 version.  The last barrier I had to overcome was remembering that emby-server runs as user "emby".  After setting the global environment to the same as my normal user (LIBVA_DRIVERS_PATH, LIBVA_DRIVER_NAME, LD_LIBRARY_PATH, and MFX_HOME) in /etc/environment and rebooting, the magic finally happened.  I compiled ffmpeg using the standard Ubuntu instructions and simply added --enable-libmfx to the configure command...  I did have to move the libmfx.pc into the pkgconfig directory for ffmpeg (~/ffmpeg_build/lib/pkgconfig/) for the configure/make to succeed.

 

https://software.intel.com/en-us/articles/how-to-setup-media-server-studio-on-secondary-os-of-linux

 

http://www.intel.com/content/dam/www/public/us/en/documents/white-papers/quicksync-video-ffmpeg-install-valid.pdf (only used to set up the libmfx.pc - WATCH FOR EXTRA SPACES if you cut and paste from the pdf, next to the "_" characters.)

 

and

 

https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu

 

This may be old news but thought I would pass on my experience...

Edited by rlw6534
Link to comment
Share on other sites

I could quote the Intel Media guys directly, but I don't want to dig up the link again, as I have posted it in the Emby forums before. Here is the beef anyway: ON LINUX the intel ARK mentioned capabilities do not mean anything. They show that you have the needed hardware, and it works in Windows.

 

On Linux, you can do quicksync (talking about qsv enc/dec) only if the CPU&GPU is supported by the Intel Media Server Studio. Period. HW identifiers are hard coded in their closed source driver. So no quicksync in Linux for you sir!

 

Please visit Intel media forums where you quickly find out the same information. Large number of people getting the same answer that "even though your chip is listed as quicksync capable in the ARK, Intel doesn't currently offer quicksync for any other chips than listed in the Media Server Studio requirements.

 

Vaapi in linux works for all quicksync(hardware capable) devices, so that is currently the only way for you to transcode in hardware (Linux. In Windows you can use quicksync).

 

The guide you yourself linked (that is the correct guide) does not list your Pentium. -> It does not work.

 

Is there a place I could write a sticky about it?

 

BR,

Andy777

Sounds like VAAPI is the way to go. No need to brother with quicksync give it's limited hardware support and complicated setup.

 

 

Sent from my iPhone using Tapatalk

Link to comment
Share on other sites

To be honest, the behaviour of Intel just sucks ass.

 

Their 01.org Projects I tried were all pretty fixed on a kernel or to be patched etc. pp , no rpm deb etc. and a lot of projects just lack on documentation.

 

It`s just like an alibi showing what their hardware is able to run, but don` t try it for real except u are on windows

 

@andy777 

Thank you for the info, but it just shows that my thoughts are right 

Was wondering already why some checkscripts of intel wasnt recognizing my cpu as  a working one.

 

It ` s really like we have to wait for a better ffmpeg version and vaapi. The encoding works perfect, but the quality of transcoding is not really good except u watch a comic or a fixed-image movie

Link to comment
Share on other sites

Definitely can sacrifice some speed for improved quality. I'm getting 20x transcoding at the moment so have room on my Ivybridge CPU

 

 

Sent from my iPhone using Tapatalk

Link to comment
Share on other sites

Maybe there are some vaapi params we can adjust as right now it is pretty much encoder defaults.

 

Not that I know of. At least considering low bitrate (<1Mbps or < 3Mbps) scenarios. The "qp" option is for constatant-quality, and the resulting bitrate is not known ex-ante. Hence, it is not suitable for streaming media server live-transcoding.

 

It doesn't matter that much though, as the "qp" method does not substantially enhance picture quality in low bitrate scenarios.

 

We just have to wait for Vaapi to get more options. I constantly monitor Gits and mailing lists of the graphics stack (kernel level driver, drm, libva, and libva-intel-driver) and ffmeg, and have't spotted (I understand like 5% of the purpose of the commits, so I am not an authority on this) big improvements. Good news is that the libva/intel-driver group has started to build a unit-test framework around the Vaapi enc/dec, so that might be a signal that they will put more effort on the components that we are interested.

 

But some stuff coming (I do not know how useful they will be and if/when the implementation in the ffmpeg side is available):

 

"Add support for VAConfigAttribEncRateControlExt attribute. Currently bit rate control per temporal layer is disabled"

or

"Update CBR algo for H.264 per tempolar layer"

 

And my test system (that is running the pre-release graphics stack) _is_ already showing some improvements in picture quality on low bitrates. Even though it has multiple generations older chip ( n2807) than my production server (skylake i5).

 

 

BR,

Andy777

Edited by Andy777
Link to comment
Share on other sites

Sorry, I don't know whether is this thread suitable to this topic...

 

VA-API hardware transcoding works fine on my building ffmpeg.

 

But when using VA-API, the original source's SAR/DAR parameter doesn't seem to be reflected to the transcoded video.

For example, original source (1440x1080 [sAR 4:3 DAR 16:9] , Japanese terrestrial broadcasting standard) is transcoded as 4:3 aspect ratio.

When using x264 software transcoding, there is no problem.

 

Whether using VA-API or x264, there is no parameter of ffmpeg about aspect ratio.

So I think it is in the VA-API's specifications, but very inconvinient...

Link to comment
Share on other sites

Sorry, I don't know whether is this thread suitable to this topic...

 

VA-API hardware transcoding works fine on my building ffmpeg.

 

But when using VA-API, the original source's SAR/DAR parameter doesn't seem to be reflected to the transcoded video.

For example, original source (1440x1080 [sAR 4:3 DAR 16:9] , Japanese terrestrial broadcasting standard) is transcoded as 4:3 aspect ratio.

When using x264 software transcoding, there is no problem.

 

Whether using VA-API or x264, there is no parameter of ffmpeg about aspect ratio.

So I think it is in the VA-API's specifications, but very inconvinient...

 

Yes, the initial implementation is not scaling like the other encoders. Can you give some examples of how it can be improved? thanks !

Link to comment
Share on other sites

  • 1 month later...

+1 on getting vaapi working... so much less CPU stress!  

Linux Mint 18 (e.g. ubuntu 16.04) with Skylake i5

 

NOTE: I had previously tried installing intel's media server studio to get qsv working (never could) and that borked up my libva files... I had to purge *everything* related to vaapi and ffmpeg, and then re-install everything by hand.  I would suggest staying away from intel's software.

Link to comment
Share on other sites

Guest plexman

+1 on getting vaapi working... so much less CPU stress!

Linux Mint 18 (e.g. ubuntu 16.04) with Skylake i5

 

NOTE: I had previously tried installing intel's media server studio to get qsv working (never could) and that borked up my libva files... I had to purge *everything* related to vaapi and ffmpeg, and then re-install everything by hand. I would suggest staying away from intel's software.

Yes! I've now tried transcoding with VAAPI the mpeg-ts IPTV broadcast from my ISP and works perfectly. Some time ago it didn't work but now it is able to transcode it with almost 0 impact on the CPU.

 

EDIT: I was wrong, it is working because my ISP broadcasts in h264 not mpeg-ts

Edited by plexman
Link to comment
Share on other sites

chessdragon136

Apologies if this isn't the right place, but I'm stuck trying to get VA-API to run on Ubuntu.

 

The system is a Qnap TS-453A running Ubuntu in its Linux Container scenario, Emby is then set up from within Ubuntu (so this is not any QNAP app Emby installation). The processor is an Intel N3160

 

VA-API  and the 965 driver are installed as far as I can determine, and vainfo reports no issues. See the attached vainfo log

FFMPEG has been installed from djcj hybrid - Emby recognised the h264_vaapi media encoder : See server log

I (think) can encode a video file using vaapi - See manual ffmpeg log

(Edit: I can also play video using vaapi in VLC) 

The emby user is a member of group video (confirmed by "getent group video" command)

 

However, when i attempt to get Emby to use vaapi I get the below error

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

[vaapi @ 0x7ffad90170f0] Failed to create a VAAPI device

 

Tried using /dev/dri/card0 as well, but the setup does have kodi (which has been stopped) and other users have mentioned issues with card0 and kodi.

 

I'm happy to do any further tests on request, I'm a bit stumped!

 

Thank you, 

 

 

Edit2: After changing the user that EmbyServer runs as it now works.. I love the results in terms of CPU usage but the low bitrate artefacts are an issue, especially as I tend to only need transcodes for mobile devices over internet, but hopefully there will be improvements from the vaapi maintainers

ffmpeg log.txt

manual ffmpeg encode.txt

Server Log Snippet.txt

vainfo.txt

Edited by chessdragon136
Link to comment
Share on other sites

FYI, I didn't have to do anything fancy to get things working in arch linux: just install the proper drivers (follow arch wiki), and the vaapi support is working. At least according to ffmpeg.

After that, for performance, I guess it's just a question of hardware.

Link to comment
Share on other sites

  • 1 month later...

Has anybody got this working with an AMD Radeon APU? I've got an A8-7600 which has a Radeon R7 core (Kaveri). All I've read says that AMD VCE v2 is built into it, so it should be capable.

 

I'm on Ubuntu server 16.10 x64. I've installed mesa and the drivers. I've got an environment variable of LIBVA_DRIVER_NAME="radeonsi" so it can find the correct driver.

 

If I run vainfo:

$ vainfo
error: can't connect to X server!
libva info: VA-API version 0.39.2
libva info: va_getDriverName() returns 0
libva info: User requested driver 'radeonsi'
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/radeonsi_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: mesa gallium vaapi
vainfo: Supported profile and entrypoints
      VAProfileMPEG2Simple            : VAEntrypointVLD
      VAProfileMPEG2Main              : VAEntrypointVLD
      VAProfileVC1Simple              : VAEntrypointVLD
      VAProfileVC1Main                : VAEntrypointVLD
      VAProfileVC1Advanced            : VAEntrypointVLD
      VAProfileH264Baseline           : VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointVLD
      VAProfileH264High               : VAEntrypointVLD
      VAProfileNone                   : VAEntrypointVideoProc

I've custom compiled ffmpeg with vaapi support, and it's sitting in /opt/ffmpeg.

$ /opt/ffmpeg/bin/ffmpeg -encoders 2> /dev/null  | grep vaapi
 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)

However, if I run a test encode:

/opt/ffmpeg/bin/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 3.2.2 Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 6.2.0 (Ubuntu 6.2.0-5ubuntu12) 20161005
  configuration: --pkg-config-flags=--static --prefix=/opt/ffmpeg
  libavutil      55. 34.100 / 55. 34.100
  libavcodec     57. 64.101 / 57. 64.101
  libavformat    57. 56.100 / 57. 56.100
  libavdevice    57.  1.100 / 57.  1.100
  libavfilter     6. 65.100 /  6. 65.100
  libswscale      4.  2.100 /  4.  2.100
  libswresample   2.  3.100 /  2.  3.100
libva info: VA-API version 0.39.2
libva info: va_getDriverName() returns 0
libva info: User requested driver 'radeonsi'
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/radeonsi_drv_video.so
libva info: Found init function __vaDriverInit_0_39
libva info: va_openDriver() returns 0
Input #0, lavfi, from 'nullsrc=s=1280x720':
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 25 tbr, 25 tbn, 25 tbc
[h264_vaapi @ 0x565361d53de0] Encoding entrypoint not found (7 / 6).
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (h264_vaapi))
Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height

I get the same errors when I enable VAAPI in Emby and make it try and stream something. For now I want to get it working on the command line before I worry about getting Emby to do anything. I've managed to get this far after a LOT of headscratching and swearing, but I'm stumped. The only result for the first error (Encoding entrypoint not found (7 / 6).) brings me here, and I've zero clue what it means. Given the command Emby runs is basically the same, I'm guessing it's something wrong on my system, but I don't know what.

 

I've tried it with X running, and without and I get the same error, and I don't think you even need X running for it to workanyway. At least, I hope not as the box runs headless anyway.

 

Anybody have any experience with this, as it's driving me nutty?!

Edited by KingDaveRa
Link to comment
Share on other sites

 

 

VAEntrypointVLD means that your card is capable to decode this format, VAEntrypointEncSlice means that you can encode to this format.

https://wiki.archlinux.org/index.php/Hardware_video_acceleration

 

The latter type is missing from my vainfo.

 

I'd already reached that conclusion after digging through the source. So either everything I've found about the spec for the graphics card is a lie, OR I've got something wrong in the drivers or possibly the BIOS. I'd originally chopped the config down as it didn't need decent graphics support. 

 

More digging to do...

Edited by KingDaveRa
Link to comment
Share on other sites

  • 2 weeks later...

hey, 

 

i try to transcode a live channel on a kaby lake system and try to use vaapi in ffmpeg. but i also have artefacts when there is a movement in the stream. can u help me? on a haswell system i have the same issue...

ffmpeg -fflags +genpts -fpsprobesize 200 -hwaccel vaapi -hwaccel_output_format vaapi -vaapi_device /dev/dri/renderD128 -i "http://192.168.1.3:9981/stream/channelid/1463976914" -c:v h264_vaapi -force_key_frames "expr:gte(t,n_forced*5)" -vf "format=nv12|vaapi,hwupload,scale_vaapi=w=1280:h=720" -b:v 2500k -maxrate 2500k -level 31 -threads 0 -qp 19 -bf 4 -c:a aac -f mpegts udp://192.168.1.24:10000
root@ubuntu:~# ffmpeg -fflags +genpts -fpsprobesize 200 -hwaccel vaapi -hwaccel_output_format vaapi -vaapi_device /dev/dri/renderD128 -i "http://192.168.1.3:9981/stream/channelid/1463976914" -c:v h264_vaapi -force_key_frames "expr:gte(t,n_forced*5)" -vf "format=nv12|vaapi,hwupload,scale_vaapi=w=1280:h=720" -b:v 2500k -maxrate 2500k -level 31 -threads 0 -qp 19 -bf 4 -c:a aac -f mpegts udp://192.168.1.24:10000
ffmpeg version 3.2.2-2~16.04.york0 Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 5.4.1 (Ubuntu 5.4.1-4ubuntu1~16.04.york1) 20161202
  configuration: --prefix=/usr --extra-version='2~16.04.york0' --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libebur128 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --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-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared
  libavutil      55. 34.100 / 55. 34.100
  libavcodec     57. 64.101 / 57. 64.101
  libavformat    57. 56.100 / 57. 56.100
  libavdevice    57.  1.100 / 57.  1.100
  libavfilter     6. 65.100 /  6. 65.100
  libavresample   3.  1.  0 /  3.  1.  0
  libswscale      4.  2.100 /  4.  2.100
  libswresample   2.  3.100 /  2.  3.100
  libpostproc    54.  1.100 / 54.  1.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
[h264 @ 0x55d2084177c0] non-existing SPS 0 referenced in buffering period
[h264 @ 0x55d2084177c0] SPS unavailable in decode_picture_timing
[h264 @ 0x55d2084177c0] non-existing PPS 0 referenced
[h264 @ 0x55d2084177c0] non-existing SPS 0 referenced in buffering period
[h264 @ 0x55d2084177c0] SPS unavailable in decode_picture_timing
[h264 @ 0x55d2084177c0] non-existing PPS 0 referenced
[h264 @ 0x55d2084177c0] decode_slice_header error
[h264 @ 0x55d2084177c0] no frame!
[h264 @ 0x55d2084177c0] non-existing SPS 0 referenced in buffering period
[h264 @ 0x55d2084177c0] SPS unavailable in decode_picture_timing
[h264 @ 0x55d2084177c0] non-existing PPS 0 referenced
[h264 @ 0x55d2084177c0] non-existing SPS 0 referenced in buffering period
[h264 @ 0x55d2084177c0] SPS unavailable in decode_picture_timing
[h264 @ 0x55d2084177c0] non-existing PPS 0 referenced
[h264 @ 0x55d2084177c0] decode_slice_header error
[h264 @ 0x55d2084177c0] no frame!
[h264 @ 0x55d2084177c0] non-existing SPS 0 referenced in buffering period
[h264 @ 0x55d2084177c0] SPS unavailable in decode_picture_timing
[h264 @ 0x55d2084177c0] non-existing PPS 0 referenced
[h264 @ 0x55d2084177c0] non-existing SPS 0 referenced in buffering period
[h264 @ 0x55d2084177c0] SPS unavailable in decode_picture_timing
[h264 @ 0x55d2084177c0] non-existing PPS 0 referenced
[h264 @ 0x55d2084177c0] decode_slice_header error
[h264 @ 0x55d2084177c0] no frame!
[h264 @ 0x55d2084177c0] non-existing SPS 0 referenced in buffering period
[h264 @ 0x55d2084177c0] SPS unavailable in decode_picture_timing
[h264 @ 0x55d2084177c0] non-existing PPS 0 referenced
[h264 @ 0x55d2084177c0] non-existing SPS 0 referenced in buffering period
[h264 @ 0x55d2084177c0] SPS unavailable in decode_picture_timing
[h264 @ 0x55d2084177c0] non-existing PPS 0 referenced
[h264 @ 0x55d2084177c0] decode_slice_header error
[h264 @ 0x55d2084177c0] no frame!
[h264 @ 0x55d2084177c0] non-existing SPS 0 referenced in buffering period
[h264 @ 0x55d2084177c0] SPS unavailable in decode_picture_timing
[h264 @ 0x55d2084177c0] non-existing PPS 0 referenced
[h264 @ 0x55d2084177c0] non-existing SPS 0 referenced in buffering period
[h264 @ 0x55d2084177c0] SPS unavailable in decode_picture_timing
[h264 @ 0x55d2084177c0] non-existing PPS 0 referenced
[h264 @ 0x55d2084177c0] decode_slice_header error
[h264 @ 0x55d2084177c0] no frame!
[h264 @ 0x55d2084177c0] non-existing SPS 0 referenced in buffering period
[h264 @ 0x55d2084177c0] SPS unavailable in decode_picture_timing
[h264 @ 0x55d2084177c0] non-existing PPS 0 referenced
[h264 @ 0x55d2084177c0] non-existing SPS 0 referenced in buffering period
[h264 @ 0x55d2084177c0] SPS unavailable in decode_picture_timing
[h264 @ 0x55d2084177c0] non-existing PPS 0 referenced
[h264 @ 0x55d2084177c0] decode_slice_header error
[h264 @ 0x55d2084177c0] no frame!
[h264 @ 0x55d2084177c0] non-existing SPS 0 referenced in buffering period
[h264 @ 0x55d2084177c0] SPS unavailable in decode_picture_timing
[h264 @ 0x55d2084177c0] non-existing PPS 0 referenced
[h264 @ 0x55d2084177c0] non-existing SPS 0 referenced in buffering period
[h264 @ 0x55d2084177c0] SPS unavailable in decode_picture_timing
[h264 @ 0x55d2084177c0] non-existing PPS 0 referenced
[h264 @ 0x55d2084177c0] decode_slice_header error
[h264 @ 0x55d2084177c0] no frame!
[h264 @ 0x55d2084177c0] Increasing reorder buffer to 2
Input #0, mpegts, from 'http://192.168.1.3:9981/stream/channelid/1463976914':
  Duration: N/A, start: 15359.518644, bitrate: N/A
  Program 11110
    Metadata:
      service_name    : ?ZDF HD
      service_provider: ?ZDFvision
    Stream #0:0[0x17de]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p(tv, bt709, progressive), 1280x720 [SAR 1:1 DAR 16:9], 50 fps, 50 tbr, 90k tbn, 100 tbc
    Stream #0:1[0x17e8](deu): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, s16p, 256 kb/s
    Stream #0:2[0x17e9](mis): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, s16p, 192 kb/s
    Stream #0:3[0x17ea](deu): Audio: ac3 ([6][0][0][0] / 0x0006), 48000 Hz, stereo, fltp, 448 kb/s
    Stream #0:4[0x17eb](mul): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, s16p, 192 kb/s
    Stream #0:5[0x17f2](deu): Subtitle: dvb_teletext ([6][0][0][0] / 0x0006), 492x250
    Stream #0:6[0x17f3](deu): Subtitle: dvb_subtitle ([6][0][0][0] / 0x0006) (hearing impaired)
Output #0, mpegts, to 'udp://192.168.1.24:10000':
  Metadata:
    encoder         : Lavf57.56.100
    Stream #0:0: Video: h264 (h264_vaapi) (High), vaapi_vld, 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 2500 kb/s, 50 fps, 90k tbn, 50 tbc
    Metadata:
      encoder         : Lavc57.64.101 h264_vaapi
    Stream #0:1(deu): Audio: aac (LC), 48000 Hz, stereo, fltp, 128 kb/s
    Metadata:
      encoder         : Lavc57.64.101 aac
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> h264 (h264_vaapi))
  Stream #0:1 -> #0:1 (mp2 (native) -> aac (native))
Press [q] to stop, [?] for help
[h264 @ 0x55d20843e2e0] Hardware accelerated decoding with frame threading is known to be unstable and its use is discouraged.
[h264 @ 0x55d20843e2e0] co located POCs unavailable
[h264 @ 0x55d2084488a0] co located POCs unavailable
Input stream #0:0 frame changed from size:1280x720 fmt:yuv420p to size:1280x720 fmt:vaapi_vld
frame= 1317 fps= 55 q=-0.0 size=    9095kB time=00:00:26.78 bitrate=2782.2kbits/s speed=1.12x
root@ubuntu:~# vainfo
error: can't connect to X server!
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) Kabylake - 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          :	VAEntrypointEncSlice
      VAProfileHEVCMain               :	VAEntrypointVLD
      VAProfileHEVCMain               :	VAEntrypointEncSlice
      VAProfileHEVCMain10             :	VAEntrypointVLD
      VAProfileVP9Profile0            :	VAEntrypointVLD
      VAProfileVP9Profile2            :	VAEntrypointVLD
Link to comment
Share on other sites

The video quality params we pass to VA API most likely need adjustment:

-vf "format=nv12|vaapi,hwupload,scale_vaapi=w=1280:h=720" -b:v 2500k -maxrate 2500k -level 31 -threads 0 -qp 19 -bf 4

Is there someone who might like to help with researching that? Thanks !

Link to comment
Share on other sites

Really is a probblem i try to do different things not only like here,

i try also to combine various things but on slow motion are all perfect, when immage are accelerating a lot of huge pixels ans shadows come up.

my build:

root@Kingdel:~# avconv -encoders | grep vaapi
ffmpeg version 3.2.2-2~16.04.york0 Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 5.4.1 (Ubuntu 5.4.1-4ubuntu1~16.04.york1) 20161202
  configuration: --prefix=/usr --extra-version='2~16.04.york0' --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libebur128 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --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-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared
  libavutil      55. 34.100 / 55. 34.100
  libavcodec     57. 64.101 / 57. 64.101
  libavformat    57. 56.100 / 57. 56.100
  libavdevice    57.  1.100 / 57.  1.100
  libavfilter     6. 65.100 /  6. 65.100
  libavresample   3.  1.  0 /  3.  1.  0
  libswscale      4.  2.100 /  4.  2.100
  libswresample   2.  3.100 /  2.  3.100
  libpostproc    54.  1.100 / 54.  1.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)

i use avconv with this configs:

 

-vf "format=nv12|vaapi,hwupload,scale_vaapi=w=1280:h=720"

"-preset baseline -bf 4 -g 100 -qp 23 -level 31"

"-preset Main -bf 4 -g 100 -qp 23 -level 41"

"-preset High -bf 4 -g 100 -qp 23 -level 51"

all this trying to encapsulate into rtmp("rtmp://my_nginx_server/localmedia/vaapi_test") a live stream ("<my_streamer_url>:<port>/<output_path>/<stream_key>"

asuming this info from hw_vaapi page

did anyone find a valid solution ?

My CPU are a kaby lake:

Last login: Tue Feb 14 02:17:36 2017 from 192.168.1.12
root@Kingdel:~# cat /proc/cpuinfo
processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 142
model name      : Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz
stepping        : 9
microcode       : 0x3c
cpu MHz         : 400.000
cache size      : 4096 KB
physical id     : 0
siblings        : 4
core id         : 0
cpu cores       : 2
apicid          : 0
initial apicid  : 0
fpu             : yes
fpu_exception   : yes
cpuid level     : 22
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov                                                                                                                                                              pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdt                                                                                                                                                             scp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_ts                                                                                                                                                             c aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 sdbg                                                                                                                                                              fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer ae                                                                                                                                                             s xsave avx f16c rdrand lahf_lm abm 3dnowprefetch epb intel_pt tpr_shadow vnmi f                                                                                                                                                             lexpriority ept vpid fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid mpx rd                                                                                                                                                             seed adx smap clflushopt xsaveopt xsavec xgetbv1 dtherm ida arat pln pts hwp hwp                                                                                                                                                             _notify hwp_act_window hwp_epp
bugs            :
bogomips        : 5807.87
clflush size    : 64
cache_alignment : 64
address sizes   : 39 bits physical, 48 bits virtual
power management:

processor       : 1
vendor_id       : GenuineIntel
cpu family      : 6
model           : 142
model name      : Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz
stepping        : 9
microcode       : 0x3c
cpu MHz         : 400.000
cache size      : 4096 KB
physical id     : 0
siblings        : 4
core id         : 1
cpu cores       : 2
apicid          : 2
initial apicid  : 2
fpu             : yes
fpu_exception   : yes
cpuid level     : 22
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov                                                                                                                                                              pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdt                                                                                                                                                             scp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_ts                                                                                                                                                             c aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 sdbg                                                                                                                                                              fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer ae                                                                                                                                                             s xsave avx f16c rdrand lahf_lm abm 3dnowprefetch epb intel_pt tpr_shadow vnmi f                                                                                                                                                             lexpriority ept vpid fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid mpx rd                                                                                                                                                             seed adx smap clflushopt xsaveopt xsavec xgetbv1 dtherm ida arat pln pts hwp hwp                                                                                                                                                             _notify hwp_act_window hwp_epp
bugs            :
bogomips        : 5807.87
clflush size    : 64
cache_alignment : 64
address sizes   : 39 bits physical, 48 bits virtual
power management:

processor       : 2
vendor_id       : GenuineIntel
cpu family      : 6
model           : 142
model name      : Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz
stepping        : 9
microcode       : 0x3c
cpu MHz         : 400.000
cache size      : 4096 KB
physical id     : 0
siblings        : 4
core id         : 0
cpu cores       : 2
apicid          : 1
initial apicid  : 1
fpu             : yes
fpu_exception   : yes
cpuid level     : 22
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov                                                                                                                                                              pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdt                                                                                                                                                             scp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_ts                                                                                                                                                             c aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 sdbg                                                                                                                                                              fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer ae                                                                                                                                                             s xsave avx f16c rdrand lahf_lm abm 3dnowprefetch epb intel_pt tpr_shadow vnmi f                                                                                                                                                             lexpriority ept vpid fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid mpx rd                                                                                                                                                             seed adx smap clflushopt xsaveopt xsavec xgetbv1 dtherm ida arat pln pts hwp hwp                                                                                                                                                             _notify hwp_act_window hwp_epp
bugs            :
bogomips        : 5807.87
clflush size    : 64
cache_alignment : 64
address sizes   : 39 bits physical, 48 bits virtual
power management:

processor       : 3
vendor_id       : GenuineIntel
cpu family      : 6
model           : 142
model name      : Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz
stepping        : 9
microcode       : 0x3c
cpu MHz         : 400.000
cache size      : 4096 KB
physical id     : 0
siblings        : 4
core id         : 1
cpu cores       : 2
apicid          : 3
initial apicid  : 3
fpu             : yes
fpu_exception   : yes
cpuid level     : 22
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov                                                                                                                                                              pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdt                                                                                                                                                             scp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_ts                                                                                                                                                             c aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 sdbg                                                                                                                                                              fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer ae                                                                                                                                                             s xsave avx f16c rdrand lahf_lm abm 3dnowprefetch epb intel_pt tpr_shadow vnmi f                                                                                                                                                             lexpriority ept vpid fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid mpx rd                                                                                                                                                             seed adx smap clflushopt xsaveopt xsavec xgetbv1 dtherm ida arat pln pts hwp hwp                                                                                                                                                             _notify hwp_act_window hwp_epp
bugs            :
bogomips        : 5807.87
clflush size    : 64
cache_alignment : 64
address sizes   : 39 bits physical, 48 bits virtual
power management:

Edited by libnc
Link to comment
Share on other sites

 

"-preset baseline -bf 4 -g 100 -qp 23 -level 31"

"-preset Main -bf 4 -g 100 -qp 23 -level 41"

"-preset High -bf 4 -g 100 -qp 23 -level 51"

all this trying to encapsulate into rtmp("rtmp://my_nginx_server/localmedia/vaapi_test") a live stream ("<my_streamer_url>:<port>/<output_path>/<stream_key>"

asuming this info from hw_vaapi page

Those look like libx264 AVConv options. h264_vaapi encoder will happily ignore all "preset" flags. If you type "ffmpeg -h encoder=h264_vaapi", you find out that vaapi AVConv options only include: -qp (ignored if bitrate is set), -quality (defaults to best), and -low_power (experimental). I´m pretty sure it is the same with avconv.

Link to comment
Share on other sites

The video quality params we pass to VA API most likely need adjustment:

-vf "format=nv12|vaapi,hwupload,scale_vaapi=w=1280:h=720" -b:v 2500k -maxrate 2500k -level 31 -threads 0 -qp 19 -bf 4

Is there someone who might like to help with researching that? Thanks !

 

There is not currently much to do. Vaapi sucks on low bitrates. I'm running Intel nightly kernel+Vaapi 0.40.0 and Intel driver 1.8.0.pre1 and ffmpeg of yesterday's git top, and I don't see any massive quality improvements. I have done a lot of tests with both CBR and VBR modes.

 

HOWEVER, there are currently couple of issues regarding vaapi and emby:

 

1) when using browser as a client, vaapi scaling goes wrong. When selecting 720p, Emby creates ffmpeg option with scale_vaapi=w=720:h=404", which of course is not 720p. It shoud be w=1280:h=720.

 

2) The current release of Emby doesn't specify video bitrate (but only -maxrate). Vaapi doesn't respect the -maxrate option (after all, it is a "hint" option) as well as x264. Lack of video bitrate (and disrespect of -maxrate) causes ffmpeg-vaapi to create bitrates that exceed -maxrate. On low bitrates, the true bitrate can be multiple times the maxrate, and constantly (so not only in the peaks).

 

The 2) needs verification from somebody running stock/release vaapi and ffmpeg, since the ones I run are built from the nightly development versions.

 

BR;

Andy777

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...