Jump to content

What is the current status of hardware acceleration


Maximus Naxsus

Recommended Posts

Waldonnis

Hehehe, time is always tight on certain days, but I can usually squeeze in some testing if my computer isn't churning away on something already...plus it's fun to try stuff that I don't have access to normally or wouldn't use otherwise myself.  For as much time as I've spent playing with hardware encoding, it's something I rarely use personally since they all lack some options that I need for certain types of material and are generally less flexible than x264/x265.  Generally, though, experimentation and the knowledge gained from it is just another tool in the toolbox and worth the time investment.  Never know when it could come in handy and end up saving you more time than you put into learning about it.

 

Glad the quality looks good, btw!

 

I'll have to go through some of my samples and files to see what to test with.  I think I still have a BD remux laying around (or five; I'm lazy about deleting), along with some 60fps and HDR clips.  I should have more info on what options do what and any shortcomings once I can knock out a few tests locally...as well as answer my 10bit encoding question that's been nagging at me since the patch adding AMF support was committed.

Link to comment
Share on other sites

Waldonnis

The h264_amf encoder is acting oddly in my testing so far, but only for one particular source file (a pretty standard BD remux).  Looking at the trace output, it's telling the driver the target bitrate and the driver is setting it...but then seems to ignore it.  The source bitrate is around 23Mbit and my target is 10Mbit, but when it's encoding, it starts around 4.3Mbit and slowly declines to ~1.4Mbit after a minute or two of video.  This results in bands of bad macroblocking and other artifacts.  What's puzzing is that the same exact command line with a different input file (30Mbit jellyfish sample) works fine and the output bitrate is what I specified.  Even stranger, the hevc_amf encoder with the same command line otherwise also seems to work fine with both the BD remux and jellyfish sample, so this is only happening with h264_amf and this one source file for some unknown reason.

 

Guess I'll move another remux over and run a few traces on the commands that worked to see if I can spot what's going on with this.

 

I also ran a quick test with a 2160p60 sample and could not get the hevc_amf encoding rate to match or exceed the native framerate (hovered around 41fps), so there may be a card or driver limitation involved.  HEVC Main 10 output is also apparently impossible with at least this card, and I'm not seeing the necessary support in the AMF header files either (I might have overlooked it, to be fair).  May just be something that has yet to be added or, again, a limitation of the driver or card.

 

Edit: scratch all of that.  Seems like I needed to explicitly enable filler data (-filler data 1) for that file.  The scene I was testing with was dark and had few changes for several seconds at a time.  Strange that it needed this, but *shrug*...I never looked at the source file that closely.

 

Further update:  cqp mode is an odd duck.  The code supposedly maps the qmin/qmax values, but I couldn't get that to work...changing qp_i/qp_p/qp_b worked, though. I also couldn't seem to figure out the vbr_peakrate, but I haven't looked at what values/options it expects for that and was just taking stabs at what I thought it might use.  GOP length is ~10secs for this input, which was expected.

 

In all, h.264 output quality wasn't bad when given an ample bitrate (8-10Mbit), and was decent even at lower bitrates (circa 2-3Mbit).  Differences between the three quality settings are minor, and I doubt 'quality' would be too useful in most circumstances compared to 'speed' or 'balanced'.  Still a few things to check out, including more dabbling with hevc_amf.  I'm hoping I can get to them before I have to give this machine back  :P

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

Yes.  If you're AMD, you're pretty much out of luck unless you have an nVidia GPU and want to use nvenc, which is flaky and limited to 2 encodes.

I was hoping to try out the nvenc on ubuntu.... am I going ot have to recompile ffmpeg myself, or do you know of an appropriate source for a binary version?

 

Thanks

Link to comment
Share on other sites

mastrmind11

I was hoping to try out the nvenc on ubuntu.... am I going ot have to recompile ffmpeg myself, or do you know of an appropriate source for a binary version?

 

Thanks

If I'm not mistaken, the ffmpeg that comes packaged w/ Emby already supports it.  But I might be mistaken.

Link to comment
Share on other sites

No, we only include VAAPI, so you'd have to bring your own ffmpeg and replace ours.

Thanks Luke, works like a charm, cuts my CPU usage in half this way, and I usually dont do more than 2 streams, Thanks!

Link to comment
Share on other sites

  • 4 weeks later...
  • 1 month later...

The next release of Emby Server for Linux x64 will include NVENC support out of the box so all you need to do is enable it. 

 

Nvidia Cuda and OpenCL drivers will need to be installed first. These cannot be freely distributed by us so you will need to refer to your respective distro to learn how to install them.

 

Thanks !

Link to comment
Share on other sites

aaronvt

The next release of Emby Server for Linux x64 will include NVENC support out of the box so all you need to do is enable it. 

 

Nvidia Cuda and OpenCL drivers will need to be installed first. These cannot be freely distributed by us so you will need to refer to your respective distro to learn how to install them.

 

Thanks !

 

Thats great Luke, now I wont keep having to remember to replace ffmpeg when I upgrade.  Do both Cuda and OpenCL need to be installed though?  thanks

Aaron

Link to comment
Share on other sites

  • 4 weeks later...
dapharsyde

No, we only include VAAPI, so you'd have to bring your own ffmpeg and replace ours.

 

Hi Luke - I am using the 3.3.1.0 .deb package from the linux download site - https://emby.media/linux-server.html

 

I wanted to try VA-API transcoding, which I enabled in my settings, and it found my DRI device, /dev/dri/renderD128

 

I restarted Emby, and upon transcoding a file, I noticed that ffmpeg still uses the libx264 codec, and never h264_amf nor h264_vaapi.

 

Executing ffmpeg -codec from the /opt/emby-server/bin folder includes this output:

 

DEV.LS h264                 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (decoders: h264 h264_v4l2m2m ) (encoders: libx264 libx264rgb h264_v4l2m2m h264_vaapi )

 

So it seems that h264_vaapi is available, but not being invoked.  Is there an additional setting or configuration I need to modify?

Link to comment
Share on other sites

Hi Luke - I am using the 3.3.1.0 .deb package from the linux download site - https://emby.media/linux-server.html

 

I wanted to try VA-API transcoding, which I enabled in my settings, and it found my DRI device, /dev/dri/renderD128

 

I restarted Emby, and upon transcoding a file, I noticed that ffmpeg still uses the libx264 codec, and never h264_amf nor h264_vaapi.

 

Executing ffmpeg -codec from the /opt/emby-server/bin folder includes this output:

 

DEV.LS h264                 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (decoders: h264 h264_v4l2m2m ) (encoders: libx264 libx264rgb h264_v4l2m2m h264_vaapi )

 

So it seems that h264_vaapi is available, but not being invoked.  Is there an additional setting or configuration I need to modify?

 

Sometimes there are files that vaapi doesn't support and we have to use software. Best thing to do is discuss an example and attach the information requested in how to report a problem. thanks.

Link to comment
Share on other sites

dapharsyde

Sometimes there are files that vaapi doesn't support and we have to use software. Best thing to do is discuss an example and attach the information requested in how to report a problem. thanks.

 

Hmm, it looks like I'm in the same situation as this guy - https://emby.media/community/index.php?/topic/55988-hadware-transcode-ubuntu-1710-vaapi-and-amd/

 

I also have an AMD CPU on an Ubuntu system with the mesa drivers.

 

His solution was to switch to an intel system, which isn't a viable option for me right now.

 

Do I need to compile my own version of ffmpeg to enable this functionality?

 

Edit: it looks like that's what he tried too, but ran into trouble with shared libraries.  :/

Edited by dapharsyde
Link to comment
Share on other sites

You don't need to do anything with compiling ffmpeg. To be honest I don't fully understand why that user feels he needs to build his own. Best thing to do is discuss an example and attach the information requested in how to report a problem. thanks.

Link to comment
Share on other sites

dapharsyde

From @@dcrdev, he writes:

 

This is because the ffmpeg bundled with emby is compiled against the amdgpu kernel implementation of the radeonsi driver. Ubuntu uses radeon/gallium for pre GCN 1.2 cards a la a8-7600, support for GCN 1.1 in amdgpu is considered experimental. 

 

The correct DRM driver implementation for gallium, is gallium_drv_video.so - ffmpeg would have to be built against that for it to work. So yes you'd have to supply a custom build, which is problematic because of the self contained nature of the package - you'd also have to modify the startup script to remove the lib directory export and revert to externally managed dependencies; or create symbolic links.

 

I don't believe gallium is well supported by vaapi anyway - it only has a limited number of working extensions; so may not be worth it.

 

 

 

 
I'm using the radeon driver, but the bundled version of ffmpeg is compiled against radeonsi.
Edited by dapharsyde
Link to comment
Share on other sites

dapharsyde

Well, I compiled my own ffmpeg with vaapi support, and succeeded in invoking a transcode with the vaapi device.  Unfortunately, it transcodes at 2 fps, whereas libx264 does 170+ fps.  The card is a Radeon R9 270X, so the slow performance doesn't seem right, I might have to troubleshoot this further with the ffmpeg devs.

 

 ./ffmpeg -vaapi_device /dev/dri/renderD128 -i /raid5vol02/video/livetv/24745_20180423010432.ts -vf 'format=nv12,hwupload' -c:v h264_vaapi -bf 0 -c:a copy /tmp/out.mp4
ffmpeg version N-90811-g2442cf3 Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 7 (Ubuntu 7.3.0-16ubuntu3)
  configuration: --prefix=/home/dapharsyde/ffmpeg_build --pkg-config-flags=--static --extra-cflags=-I/home/dapharsyde/ffmpeg_build/include --extra-ldflags=-L/home/dapharsyde/ffmpeg_build/lib --extra-libs='-lpthread -lm' --bindir=/home/dapharsyde/bin --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfree --enable-vaapi
  libavutil      56. 15.100 / 56. 15.100
  libavcodec     58. 19.100 / 58. 19.100
  libavformat    58. 13.100 / 58. 13.100
  libavdevice    58.  4.100 / 58.  4.100
  libavfilter     7. 19.100 /  7. 19.100
  libswscale      5.  2.100 /  5.  2.100
  libswresample   3.  2.100 /  3.  2.100
  libpostproc    55.  2.100 / 55.  2.100
Input #0, mpegts, from '/raid5vol02/video/livetv/24745_20180423010432.ts':
  Duration: 00:10:29.17, start: 35420.341567, bitrate: 3803 kb/s
  Program 1
    Stream #0:0[0xefd]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p(progressive), 1280x720 [SAR 1:1 DAR 16:9], Closed Captions, 59.94 fps, 59.94 tbr, 90k tbn, 119.88 tbc
    Stream #0:1[0xefe](eng): Audio: ac3 ([129][0][0][0] / 0x0081), 48000 Hz, 5.1(side), fltp, 384 kb/s
    Stream #0:2[0xeff](spa): Audio: ac3 ([129][0][0][0] / 0x0081), 48000 Hz, mono, fltp, 64 kb/s
    Stream #0:3[0xf00]: Data: scte_35
    Stream #0:4[0xf01]: Unknown: none (ETV1 / 0x31565445)
    Stream #0:5[0xf02]: Unknown: none (ETV1 / 0x31565445)
    Stream #0:6[0xf28]: Unknown: none ([192][0][0][0] / 0x00C0)
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 @ 0x55caf4b35200] co located POCs unavailable
[h264 @ 0x55caf4b83140] concealing 3215 DC, 3215 AC, 3215 MV errors in B frame
[h264_vaapi @ 0x55caf4c56dc0] Warning: some packed headers are not supported (want 0xd, got 0).
[mp4 @ 0x55caf4b35b00] track 1: codec frame size is not set
Output #0, mp4, to '/tmp/out.mp4':
  Metadata:
    encoder         : Lavf58.13.100
    Stream #0:0: Video: h264 (h264_vaapi) (Constrained Baseline) (avc1 / 0x31637661), vaapi_vld, 1280x720 [SAR 1:1 DAR 16:9], q=0-31, 59.94 fps, 60k tbn, 59.94 tbc
    Metadata:
      encoder         : Lavc58.19.100 h264_vaapi
    Stream #0:1(eng): Audio: ac3 (ac-3 / 0x332D6361), 48000 Hz, 5.1(side), fltp, 384 kb/s
frame=   70 fps=2.0 q=-0.0 Lsize=     350kB time=00:00:01.15 bitrate=2492.2kbits/s dup=59 drop=0 speed=0.0324x
 
Edited by dapharsyde
Link to comment
Share on other sites

  • 2 months later...
jhoff80

Does anyone have subtitles working with hardware acceleration?  Just not sure if there's something I have configured wrong on my system, or if it's a limitation of the hardware transcode.

 

I'm using NVENC and the file in this case has PGS forced subtitles.

Link to comment
Share on other sites

Does anyone have subtitles working with hardware acceleration?  Just not sure if there's something I have configured wrong on my system, or if it's a limitation of the hardware transcode.

 

I'm using NVENC and the file in this case has PGS forced subtitles.

 

If you're having an issue, please discuss an example and please attach the information requested in how to report a media playback issue. thanks !

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