Jump to content

Testing NVENC for encoding options


snake98

Recommended Posts

snake98

Tester are need to help test the encoding options for NVENC.

 

Replace the 3 Dll's in the \Emby-Server\system directory with the ones in the Link.  You have to reapply these after every update, and it may break so please make backups of your files.  The intel qsv fix is included in this also.

 

Current options are only for the 3.3.1.11-beta

 

Current mapping is as follows to nvenc.

 

veryslow = lossless

slower, slow = slow

medium = medium,

fast,faster,supefast, ultrafast = fast

all others fall back to default, which nvidia states is medium.

 

 

Files are located here https://drive.google.com/drive/folders/1n-I1PXXL87rCi4hDpdqTjym2M6Xt90mJ?usp=sharing

 

This is split thread from intel quick sync https://emby.media/community/index.php?/topic/56730-emby-not-respecting-h264-encoding-preset-setting-on-hardware-encoding-for-intel-quick-sync/

 

 

Please report the following information if it you have problems.

 

ffmpeg-transcode log, this line

C:\Users\Snake98\AppData\Roaming\Emby-Server\system\ffmpeg.exe -analyzeduration 3000000 -fflags +igndts -i "http://127.0.0.1:8096/LiveTv/LiveStreamFiles/975d23275ddb4f3e9195f34c79563302/stream.ts" -map_metadata -1 -map_chapters -1 -threads 7 -sn -codec:v:0 h264_qsv -preset veryslow -look_ahead 0 -b:v 2616000 -maxrate 2616000 -bufsize 5232000 -profile:v high -level 4.1 -force_key_frames "expr:gte(t,n_forced*3)" -vf "yadif=0:-1:0,scale=trunc(min(max(iw\,ih*dar)\,1280)/2)*2:trunc(ow/dar/2)*2" -flags -global_header -vsync cfr -codec:a:0 aac -strict experimental -ac 2 -ab 384000  -f segment -max_delay 5000000 -avoid_negative_ts disabled -start_at_zero -segment_time 3  -individual_header_trailer 0 -segment_format mpegts -segment_list_entry_prefix "hls/83bfe1c0046e9059f405ce39ef831c3f/" -segment_list_type m3u8 -segment_start_number 0 -segment_list "z:\transcoding-temp\83bfe1c0046e9059f405ce39ef831c3f.m3u8" -y "z:\transcoding-temp\83bfe1c0046e9059f405ce39ef831c3f%d.ts"

Also I need someone to test slowest and check that it respect the bitrate you set.  example if you choose 3 megabits to stream, make sure it's streams at 3 megabits.  I read that it may not respect that.

 

Code is here

 

https://github.com/Bradmu/Emby/commit/bffa5ae378a289fbc4f1f3193967b00f32690d00

Edited by snake98
Link to comment
Share on other sites

roberto188

Testing now...

 

Worked.

 

Veryslow mapped to lossless:

 

C:\Users\Media Center\AppData\Roaming\Emby-Server\system\ffmpeg.exe -analyzeduration 3000000 -fflags +igndts -c:v mpeg2_cuvid -resize 1920x1080 -i "http://127.0.0.1:8096/LiveTv/LiveStreamFiles/226afb3b380142e683a5bb6e71424121/stream.ts"-map_metadata -1 -map_chapters -1 -threads 0 -sn -codec:v:0 h264_nvenc -pix_fmt yuv420p -preset lossless -b:v 7808001 -maxrate 7808001 -bufsize 15616002 -force_key_frames "expr:gte(t,n_forced*3)" -vf "yadif=1:-1:0" -flags -global_header -vsync cfr -codec:a:0 copy -f segment -max_delay 5000000 -avoid_negative_ts disabled -start_at_zero -segment_time 3 -individual_header_trailer 0 -segment_format mpegts -segment_list_entry_prefix "hls/e13240c4aba56e8f99baa1a827f02112/" -segment_list_type m3u8 -segment_start_number 0 -segment_list "D:\transcoding-temp\e13240c4aba56e8f99baa1a827f02112.m3u8" -y "D:\transcoding-temp\e13240c4aba56e8f99baa1a827f02112%d.ts"

 

However, it then threw an error that made it fall back to CPU encoding:

 

[h264_nvenc @ 00000000031a6080] No NVENC capable devices found

Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height

Conversion failed!

 

Slow and slower mapped to slow:

 

C:\Users\Media Center\AppData\Roaming\Emby-Server\system\ffmpeg.exe -analyzeduration 3000000 -fflags +igndts -i "http://127.0.0.1:8096/LiveTv/LiveStreamFiles/7c27d79725b24c4997c628c60894f2d3/stream.ts"-map_metadata -1 -map_chapters -1 -threads 0 -sn -codec:v:0 h264_nvenc -pix_fmt yuv420p -preset slow -b:v 7808001 -maxrate 7808001 -bufsize 15616002 -force_key_frames "expr:gte(t,n_forced*3)" -vf "yadif=1:-1:0,scale=trunc(min(max(iw\,ih*dar)\,1920)/2)*2:trunc(ow/dar/2)*2" -flags -global_header -vsync cfr -codec:a:0 copy -f segment -max_delay 5000000 -avoid_negative_ts disabled -start_at_zero -segment_time 3 -individual_header_trailer 0 -segment_format mpegts -segment_list_entry_prefix "hls/c814deab8babd442127cdfa3d243ba4d/" -segment_list_type m3u8 -segment_start_number 0 -segment_list "D:\transcoding-temp\c814deab8babd442127cdfa3d243ba4d.m3u8" -y "D:\transcoding-temp\c814deab8babd442127cdfa3d243ba4d%d.ts"

 

Medium mapped to medium:

 

C:\Users\Media Center\AppData\Roaming\Emby-Server\system\ffmpeg.exe -analyzeduration 3000000 -fflags +igndts -c:v mpeg2_cuvid -resize 1920x1080 -i "http://127.0.0.1:8096/LiveTv/LiveStreamFiles/4873d431422c4a00bb0aac6b1dd30912/stream.ts"-map_metadata -1 -map_chapters -1 -threads 0 -sn -codec:v:0 h264_nvenc -pix_fmt yuv420p -preset medium -b:v 7808001 -maxrate 7808001 -bufsize 15616002 -force_key_frames "expr:gte(t,n_forced*3)" -vf "yadif=1:-1:0" -flags -global_header -vsync cfr -codec:a:0 copy -f segment -max_delay 5000000 -avoid_negative_ts disabled -start_at_zero -segment_time 3 -individual_header_trailer 0 -segment_format mpegts -segment_list_entry_prefix "hls/9ed150ba665b302e20a1165fd9e614d3/" -segment_list_type m3u8 -segment_start_number 0 -segment_list "D:\transcoding-temp\9ed150ba665b302e20a1165fd9e614d3.m3u8" -y "D:\transcoding-temp\9ed150ba665b302e20a1165fd9e614d3%d.ts"

 

Auto and fast, faster and fastest all mapped to "default"

 

 

C:\Users\Media Center\AppData\Roaming\Emby-Server\system\ffmpeg.exe -analyzeduration 3000000 -fflags +igndts -i "http://127.0.0.1:8096/LiveTv/LiveStreamFiles/e3b4c80c02b040f48352e462ea1b7072/stream.ts"-map_metadata -1 -map_chapters -1 -threads 0 -sn -codec:v:0 h264_nvenc -pix_fmt yuv420p -preset default -b:v 7808001 -maxrate 7808001 -bufsize 15616002 -force_key_frames "expr:gte(t,n_forced*3)" -vf "yadif=1:-1:0,scale=trunc(min(max(iw\,ih*dar)\,1920)/2)*2:trunc(ow/dar/2)*2" -flags -global_header -vsync cfr -codec:a:0 copy -f segment -max_delay 5000000 -avoid_negative_ts disabled -start_at_zero -segment_time 3 -individual_header_trailer 0 -segment_format mpegts -segment_list_entry_prefix "hls/d52011eed15274bc98782caafa414d91/" -segment_list_type m3u8 -segment_start_number 0 -segment_list "D:\transcoding-temp\d52011eed15274bc98782caafa414d91.m3u8" -y "D:\transcoding-temp\d52011eed15274bc98782caafa414d91%d.ts"

 

 

Now to make the option for "fast" preset, as "default", is actually medium. I would love to test out of fast and see how many streams I can get. I also wonder what the difference between "performance" and "fast" are.

Edited by roberto188
Link to comment
Share on other sites

snake98

Testing now...

 

Worked.

 

Veryslow mapped to lossless:

 

C:\Users\Media Center\AppData\Roaming\Emby-Server\system\ffmpeg.exe -analyzeduration 3000000 -fflags +igndts -c:v mpeg2_cuvid -resize 1920x1080 -i "http://127.0.0.1:8096/LiveTv/LiveStreamFiles/226afb3b380142e683a5bb6e71424121/stream.ts"-map_metadata -1 -map_chapters -1 -threads 0 -sn -codec:v:0 h264_nvenc -pix_fmt yuv420p -preset lossless -b:v 7808001 -maxrate 7808001 -bufsize 15616002 -force_key_frames "expr:gte(t,n_forced*3)" -vf "yadif=1:-1:0" -flags -global_header -vsync cfr -codec:a:0 copy -f segment -max_delay 5000000 -avoid_negative_ts disabled -start_at_zero -segment_time 3 -individual_header_trailer 0 -segment_format mpegts -segment_list_entry_prefix "hls/e13240c4aba56e8f99baa1a827f02112/" -segment_list_type m3u8 -segment_start_number 0 -segment_list "D:\transcoding-temp\e13240c4aba56e8f99baa1a827f02112.m3u8" -y "D:\transcoding-temp\e13240c4aba56e8f99baa1a827f02112%d.ts"

 

However, it then threw an error that made it fall back to CPU encoding:

 

[h264_nvenc @ 00000000031a6080] No NVENC capable devices found

Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height

Conversion failed!

 

Slow and slower mapped to slow:

 

C:\Users\Media Center\AppData\Roaming\Emby-Server\system\ffmpeg.exe -analyzeduration 3000000 -fflags +igndts -i "http://127.0.0.1:8096/LiveTv/LiveStreamFiles/7c27d79725b24c4997c628c60894f2d3/stream.ts"-map_metadata -1 -map_chapters -1 -threads 0 -sn -codec:v:0 h264_nvenc -pix_fmt yuv420p -preset slow -b:v 7808001 -maxrate 7808001 -bufsize 15616002 -force_key_frames "expr:gte(t,n_forced*3)" -vf "yadif=1:-1:0,scale=trunc(min(max(iw\,ih*dar)\,1920)/2)*2:trunc(ow/dar/2)*2" -flags -global_header -vsync cfr -codec:a:0 copy -f segment -max_delay 5000000 -avoid_negative_ts disabled -start_at_zero -segment_time 3 -individual_header_trailer 0 -segment_format mpegts -segment_list_entry_prefix "hls/c814deab8babd442127cdfa3d243ba4d/" -segment_list_type m3u8 -segment_start_number 0 -segment_list "D:\transcoding-temp\c814deab8babd442127cdfa3d243ba4d.m3u8" -y "D:\transcoding-temp\c814deab8babd442127cdfa3d243ba4d%d.ts"

 

Medium mapped to medium:

 

C:\Users\Media Center\AppData\Roaming\Emby-Server\system\ffmpeg.exe -analyzeduration 3000000 -fflags +igndts -c:v mpeg2_cuvid -resize 1920x1080 -i "http://127.0.0.1:8096/LiveTv/LiveStreamFiles/4873d431422c4a00bb0aac6b1dd30912/stream.ts"-map_metadata -1 -map_chapters -1 -threads 0 -sn -codec:v:0 h264_nvenc -pix_fmt yuv420p -preset medium -b:v 7808001 -maxrate 7808001 -bufsize 15616002 -force_key_frames "expr:gte(t,n_forced*3)" -vf "yadif=1:-1:0" -flags -global_header -vsync cfr -codec:a:0 copy -f segment -max_delay 5000000 -avoid_negative_ts disabled -start_at_zero -segment_time 3 -individual_header_trailer 0 -segment_format mpegts -segment_list_entry_prefix "hls/9ed150ba665b302e20a1165fd9e614d3/" -segment_list_type m3u8 -segment_start_number 0 -segment_list "D:\transcoding-temp\9ed150ba665b302e20a1165fd9e614d3.m3u8" -y "D:\transcoding-temp\9ed150ba665b302e20a1165fd9e614d3%d.ts"

 

Auto and fast, faster and fastest all mapped to "default"

 

 

C:\Users\Media Center\AppData\Roaming\Emby-Server\system\ffmpeg.exe -analyzeduration 3000000 -fflags +igndts -i "http://127.0.0.1:8096/LiveTv/LiveStreamFiles/e3b4c80c02b040f48352e462ea1b7072/stream.ts"-map_metadata -1 -map_chapters -1 -threads 0 -sn -codec:v:0 h264_nvenc -pix_fmt yuv420p -preset default -b:v 7808001 -maxrate 7808001 -bufsize 15616002 -force_key_frames "expr:gte(t,n_forced*3)" -vf "yadif=1:-1:0,scale=trunc(min(max(iw\,ih*dar)\,1920)/2)*2:trunc(ow/dar/2)*2" -flags -global_header -vsync cfr -codec:a:0 copy -f segment -max_delay 5000000 -avoid_negative_ts disabled -start_at_zero -segment_time 3 -individual_header_trailer 0 -segment_format mpegts -segment_list_entry_prefix "hls/d52011eed15274bc98782caafa414d91/" -segment_list_type m3u8 -segment_start_number 0 -segment_list "D:\transcoding-temp\d52011eed15274bc98782caafa414d91.m3u8" -y "D:\transcoding-temp\d52011eed15274bc98782caafa414d91%d.ts"

 

 

Now to make the option for "fast" preset, as "default", is actually medium. I would love to test out of fast and see how many streams I can get. I also wonder what the difference between "performance" and "fast" are.

Thanks.  New build to test Fast, faster, etc to pass to fast.  Could you try the new build. 

I will look into lossless. 

Also what video card are you using, and are your drivers recent?

 

Also Lossless is only supported on gtx 750 and above, and all 800+.

Edited by snake98
Link to comment
Share on other sites

roberto188

Fast works.

 

C:\Users\Media Center\AppData\Roaming\Emby-Server\system\ffmpeg.exe -analyzeduration 3000000 -fflags +igndts -i "http://127.0.0.1:8096/LiveTv/LiveStreamFiles/d1c607a2ebeb4a1c91fc1130e9a7afca/stream.ts"-map_metadata -1 -map_chapters -1 -threads 0 -sn -codec:v:0 h264_nvenc -pix_fmt yuv420p -preset fast -b:v 7616000 -maxrate 7616000 -bufsize 15232000 -profile:v high -force_key_frames "expr:gte(t,n_forced*3)" -vf "yadif=1:-1:0,scale=trunc(min(max(iw\,ih*dar)\,min(1920\,1080*dar))/2)*2:trunc(min(max(iw/dar\,ih)\,min(1920/dar\,1080))/2)*2" -flags -global_header -vsync cfr -codec:a:0 copy -f segment -max_delay 5000000 -avoid_negative_ts disabled -start_at_zero -segment_time 3  -individual_header_trailer 0 -segment_format mpegts -segment_list_entry_prefix "hls/e75d7adafe056358e9ab0512a6970503/" -segment_list_type m3u8 -segment_start_number 0 -segment_list "D:\transcoding-temp\e75d7adafe056358e9ab0512a6970503.m3u8" -y "D:\transcoding-temp\e75d7adafe056358e9ab0512a6970503%d.ts"

 

Also, on a side note, "fast" preset is actually pretty darn good quality. I wanted an 8 mbit stream of NHL hockey 1080p 60fps on a 10 foot projection screen and it looked pretty damn good. When I upped the stream to 12 and subsequently higher it looked virtually identical to the original feed.  

 

This is fantastic!

Link to comment
Share on other sites

roberto188

Thanks.  New build to test Fast, faster, etc to pass to fast.  Could you try the new build. 

I will look into lossless. 

Also what video card are you using, and are your drivers recent?

 

Also Lossless is only supported on gtx 750 and above, and all 800+.

I have the latest drivers installed but an older GPU, a Quatro K2000.

Link to comment
Share on other sites

snake98

I have the latest drivers installed but an older GPU, a Quatro K2000.

Thanks for the info, Quatrok2000 is Kepler, which doesn't support Lossless preset, only maxwell and newer do.

 

@@Luke,

  The option for lossless is only supported on Maxwell( released in 2014) and newer, do you want me to remove it.  It only effect the slowest option, and it does fail gracefully back to cpu.

  The only thing I need someone to test is to make sure it respect the bitrate control.

 

  If your good with it, I can create a pull request to the dev branch.

Link to comment
Share on other sites

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

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