Jump to content

AMD Hardware Acceleration?


Recommended Posts

hotwheelzffx
Posted

My Emby Server is Windows 10 with an AMD FX-8120 Eight-Core CPU and an AMD Radeon R9 200 Series GPU.

 

I downloaded the latest build of FFMPEG from the source (Zeranoe) for testing.

 

Using this command, I can see via the Task Manager that my GPU is being used for transcoding:

ffmpeg -i input.mkv -c:v h264_amf -c:a output.mkv

 

From my transcoding logs; a recent stream used the following commands:

ffmpeg.exe -f matroska,webm -i file:"input.mkv" -threads 0 -map 0:0 -map 0:1 -map -0:s -codec:v:0 libx264 -vf "scale=trunc(min(max(iw\,ih*dar)\,1920)/2)*2:trunc(ow/dar/2)*2" -pix_fmt yuv420p -preset veryfast -crf 23 -maxrate 5227222 -bufsize 10454444 -x264opts:0 subme=0:me_range=4:rc_lookahead=10:me=dia:no_chroma_me:8x8dct=0:partitions=none -force_key_frames "expr:if(isnan(prev_forced_t),eq(t,t),gte(t,prev_forced_t+2))" -copyts -vsync -1 -codec:a:0 copy -f segment -max_delay 5000000 -avoid_negative_ts disabled -map_metadata -1 -map_chapters -1 -start_at_zero -segment_time 3 -individual_header_trailer 0 -segment_format mpegts -segment_list_type m3u8 -segment_start_number 0 -segment_list "E:\Xcode\transcoding-temp\4584a087a57a74fc4c852112233419bf.m3u8" -y "E:\Xcode\transcoding-temp\4584a087a57a74fc4c852112233419bf%d.ts"

 

Is there a setting or option that Emby uses to tell FFMPEG to use h264_amf?

Is that even possible or worth the performance gain/hit?

 

I am not having any issues with performance in regards to bandwidth, CPU/GPU or streams. I am just curious.

 

Posted

We haven't implemented support for h264_amf yet. In fact, our ffmpeg builds don't even currently include the libraries for it.

 

It's possible for the future but first we have to make sure we can legally distribute the libraries.

  • Like 1
hotwheelzffx
Posted

I generally have no idea what I'm talking about :)

But, for users who Bring Their Own FFMPEG, would a workaround be allowing an optional custom command line field in the transcoding settings? Or am I just over-simplifying?

Posted

No we can add direct support so that if you bring your own ffmpeg it will work.

Posted (edited)

REMOVED - with all my testing on nVidia it seems I did not restore the Emby FFMpeg and had the version I downloaded from git, sorry for the confusion. Confirmed from my staging server that amf is not included as Luke stated

 

With that being said it does not look like amf is part of the non-free package so it should be able to be included.

 

@hotwheelzffx you might want to take that ffmpeg output command and run it with amf just to ensure you do not run into issues with -vf scale

 

I would run something like the following to test, during your test use VLC or another player to try to play the .ts streams created make sure you get audio and video and everything looks as expected and no errors, I would also change the E:\Xcode\transcoding directory in your test as not to clutter up your Emby transcoding environment:

 

ffmpeg.exe -f matroska,webm -i file:"input.mkv" -threads 0 -map 0:0 -map 0:1 -map -0:s -codec:v:0 h264_amf -vf "scale=trunc(min(max(iw\,ih*dar)\,1920)/2)*2:trunc(ow/dar/2)*2" -pix_fmt yuv420p -preset veryfast -crf 23 -maxrate 5227222 -bufsize 10454444 -x264opts:0 subme=0:me_range=4:rc_lookahead=10:me=dia:no_chroma_me:8x8dct=0:partitions=none -force_key_frames "expr:if(isnan(prev_forced_t),eq(t,t),gte(t,prev_forced_t+2))" -copyts -vsync -1 -codec:a:0 copy -f segment -max_delay 5000000 -avoid_negative_ts disabled -map_metadata -1 -map_chapters -1 -start_at_zero -segment_time 3 -individual_header_trailer 0 -segment_format mpegts -segment_list_type m3u8 -segment_start_number 0 -segment_list "E:\Xcode\transcoding-temp\4584a087a57a74fc4c852112233419bf.m3u8" -y "E:\Xcode\transcoding-temp\4584a087a57a74fc4c852112233419bf%d.ts"

 

you might also try something like:

ffmpeg.exe -f matroska,webm -i file:"input.mkv" -threads 0 -map 0:0 -map 0:1 -map -0:s -codec:v:0 h264_amf -vf "scale=trunc(min(max(iw\,ih*dar)\,640)/2)*2:trunc(ow/dar/2)*2" -pix_fmt yuv420p -preset default -b:v 416000 -maxrate 416000 -bufsize 832000 -profile:v high -force_key_frames "expr:if(isnan(prev_forced_t),eq(t,t),gte(t,prev_forced_t+3))" -copyts -vsync -codec:a:0 copy -f segment -max_delay 5000000 -avoid_negative_ts disabled -map_metadata -1 -map_chapters -1 -start_at_zero -segment_time 3 -individual_header_trailer 0 -segment_format mpegts -segment_list_type m3u8 -segment_start_number 0 -segment_list "E:\Xcode\transcoding-temp\4584a087a57a74fc4c852112233419bf.m3u8" -y "E:\Xcode\transcoding-temp\4584a087a57a74fc4c852112233419bf%d.ts"

 

You might need to play with the command a little to get the desired results as options like -x264opts:0 subme=0:me_range=4:rc_lookahead=10:me=dia:no_chroma_me:8x8dct=0:partitions=none may not be supported due to not using the x264 software lib.

Edited by mbnwa
hotwheelzffx
Posted

I did not receive any errors using the command strings... Quality was less then stellar, but my originally posted stream string was for a remote user using an older Roku.

However, subsequent tests or variations of the command produced better results. 

 

ffmpeg.exe -f matroska,webm -i file:"input.mkv" -threads 0 -map 0:0 -map 0:1 -map -0:s -codec:v:0 h264_amf -profile:v high -copyts -vsync 0 -codec:a:0 copy -f segment -max_delay 5000000 -avoid_negative_ts disabled -map_metadata -1 -map_chapters -1 -start_at_zero -segment_time 3 -individual_header_trailer 0 -segment_format mpegts -segment_list_type m3u8 -segment_start_number 0 -segment_list "output.m3u8" -y "output%d.ts" 

  • 2 weeks later...
Posted

We haven't implemented support for h264_amf yet. In fact, our ffmpeg builds don't even currently include the libraries for it.

 

It's possible for the future but first we have to make sure we can legally distribute the libraries.

I'll jump in for testing this when you have it ready. I miss hardware transcoding with Emby as Plex could use my AMD GPU.

Posted

I'll add support for the amf commands for the next release. Our ffmpeg builds don't have these libraries though so currently it would require you to bring your own ffmpeg build. It's something we can look at adding in the future though.

Posted

That will be great Luke!

 

I just pulled my AMD Radeon R9 280X and put in a Gigabyte GTX 750 TI so I could get a couple of HW streams (working fine).

 

Be happy to drop the AMD back in and see roughly how much difference it makes and encoding speed differences.

 

Carlo

Posted (edited)
I did a few quick tests on my old i7 server with CPU only and two different older video cards I had laying around that should handle mpeg and H.264 but have no hvec support (I don't need it).

 

Intel® Core™ i7-930 Processor (4 cores, 8 hyper threads)

XFX Double D R9 280X Black Edition (drivers 22.19.157.3)

GIGABYTE GTX 750 Ti OC 2 GB (drivers 23.21.13.9101)

 

Unless I'm not running a late enough AMD driver the AMD support really isn't worth using from my brief testing.  I'm hoping this may just be a driver issue but the latest driver I could get to install on Windows Server 2012 R2 was 22.19.157.3 which is about a year old.  AMD driver support on Windows Server is tricky to say the least.

 

Anyway for a few brief tests I did these with the system doing nothing else.  These were all done using Days of Thunder which I had already converted to H.264 and a 30 minute 1080i DVR recordings (0 padding).

 


Days of Thunder

Size 8.15 GB

Duration 1:47:17

Bitrate 10879 kbps

Width 1920

Height 800

Level 4.1

Container MP4

Bitrate 9097 kbps (video)

Bit Depth 8

Chroma Subsampling 4:2:0

Frame Rate 23.976 fps

AAC & DTS audio tracks


 


Open House S07E68.ts (DVR 30 minute recording)

Duration 30:00

Size 2.92 GB

Duration 30:00

Bitrate 13915 kbps

Width 1920

Height 1080

Container MPEGTS

Bitrate 13435 kbps (video)

Chroma Subsampling 4:2:0

Frame Rate 29.97 fps

Video Frame Rate NTSC

Video Profile main

Scan Type interlaced

AC3 5.1 384 kbps English & AC3 Stereo 96 kbps Español audio tracks

 

For the test I performed a SYNC job for each file changing the transcode defaults to use.  Below are file file sizes of the final version of the file created, file name, method, CRF used if CPU or profile (some done via command line for nvenc fast/slow) as well as the real-time transfer rate and the overall kbs bitrate the file used.

 

This produced 1280 x 532 for Days of Thunder and 1280 x 720 for Open House (DVR).

 

It's clear looking at file size produced that AMF & NVENC produced much larger files and had to use more bitrate to achieve the same results. I tested the BOB and Bob & Weave outputs to make sure I got the 59.94 FPS I was expecting and did.

 


2,392,076,619 Days of Thunder - CPU - Auto - 5.88x - 2,973 kbs.mkv   (CRF 23)

1,514,298,436 Days of Thunder - CPU - Medium - 5.25x - 1,882 kbs.mkv (CRF 23)

1,506,092,248 Days of Thunder - CPU - Slow - 5.25x - 1,872 kbs.mkv   (CRF 23)

2,398,960,257 Days of Thunder - CPU - Slow - 4.54x - 2,98a1 kbs.mkv   (CRF 20)

 

3,177,322,201 Days of Thunder - AMF - 6.82x - 3,948 kbs.mkv

3,215,318,552 Days of Thunder - NVENC - Auto/Default - 20.5x - 3,995 kbs.mkv

3,216,046,047 Days of Thunder - NVENC - Fast - 19.3x - 3,996 kbs.mkv (command line)

3,215,058,371 Days of Thunder - NVENC - Slow - 18x - 3,995 kbs.mkv (command line)

 

 

681,356,648 Open House S07E68 - CPU - Bob - 3.34x - 3,028 kbs.mkv (CRF 23)

864,606,221 Open House S07E68 - AMF - Bob - 2.98x - 3,842 kbs.mkv

881,173,901 Open House S07E68 - NVENC-Bob - 8.62x - 3,916 kbs.mkv

 

696,581,998 Open House S07E68 - CPU - B&W - 1.88x - 3,095 kbs.mkv (CRF 23)

879,886,388 Open House S07E68 - AMF - B&W - 1.69x - 3,910 kbs.mkv

866,983,873 Open House S07E68 - NVENC-B&W - 6.54x - 3 853 kbs.mkv

 

2,010,866,602 Days of Thunder - Plex NVENC - 3Mb 720 - 5.6x - 2,499 kbs.mp4

721,005,009 Open House S07E68 - Plex AMD - 3Mb 720 - 2.6x - 3 204 kbs.mp4

536,234,148 Open House S07E68 - Plex NVENC - 3Mb 720 - 2.9x - 2,383 kbs.mp4

 

All files produced visually fine outputs that I'd have no problem using.  Obviously the larger file sizes (higher bitrates) could be counter productive in certain environments (storage space on mobile) or low upload bandwidth.

 

AMF (AMD) hardly seemed worth the effort.  I'm hoping others get different results than I did so I can re-investigate this.  Technically the R9 280x card should be better than the GTX 750 TI (or I would have thought it was and wouldn't have the 2 stream limit that NVENC has for consumer cards).

 

For CPU only on my system MEDIUM profile was much better than auto (superfast) at very little extra overhead.  I also included three "similar" sync conversions done via Plex sync with a profile using 720p 3Mb as the target. I probably should have used 4MB to make these more comparable in bitrate.  But interestingly Plex was much slower converting nvenc encodes.

 

I saved all command lines and logs that Emby/Plex used as well as the files produced.

 

Just thought I'd share what I found thus far,

Carlo

Edited by cayars
  • Like 1

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