[SOLVED] Utlizing NVIDIA DECODER inside the FFMpeg custom encode node

Questions and answers on how to get the most out of FFAStrans
Post Reply
veks
Posts: 84
Joined: Fri Oct 25, 2019 6:51 am

[SOLVED] Utlizing NVIDIA DECODER inside the FFMpeg custom encode node

Post by veks »

Hi all!
I'm trying to figure out how to utilize NVDEC inside the FFMpeg custom node.
I've tried, and I always get this error:
Image

The command I'm using inside the FFMpeg custom node is:

-pix_fmt yuv420p -vf "scale=960:540,yadif=1" -vsync 1 -hwaccel cuvid -hwaccel_device 1 -hwaccel cuda -hwaccel_output_format cuda -vcodec h264_nvenc -r 25 -g 25 -b:v 1700k -bufsize 1216k -maxrate 1800k -preset medium -profile:v main -acodec aac -b:a 64k -ac 2 -ar 48000 -af "aresample=async=1:min_hard_comp=0.100000:first_pts=0"

Thanks!
Last edited by veks on Mon Mar 21, 2022 12:30 pm, edited 1 time in total.
admin
Site Admin
Posts: 1687
Joined: Sat Feb 08, 2014 10:39 pm

Re: Utlizing NVIDIA DECODER inside the FFMpeg custom encode node

Post by admin »

Hi Vedran,

The "hwaccel" options are input options and cannot be used as output options. However, when using the custom ffmpeg encoder you cannot currently specify any input options so your only option is to use command executor:

%comspec% /C ""%s_ffmpegx64%" -hwaccel cuvid -hwaccel_device 1 -hwaccel cuda -hwaccel_output_format cuda -i "%s_source%" -pix_fmt yuv420p -vf "scale=960:540,yadif=1" -vsync 1 -vcodec h264_nvenc -r 25 -g 25 -b:v 1700k -bufsize 1216k -maxrate 1800k -preset medium -profile:v main -acodec aac -b:a 64k -ac 2 -ar 48000 -af "aresample=async=1:min_hard_comp=0.100000:first_pts=0" -y "x:\some path\file.mp4""

And of course it's good practice to make sure your command works in normal dos before trying to implement it in ffastrans :-)

-steinar
veks
Posts: 84
Joined: Fri Oct 25, 2019 6:51 am

Re: Utlizing NVIDIA DECODER inside the FFMpeg custom encode node

Post by veks »

Hi,
I've tried using the command node with this command, any idea what's wrong?

Code: Select all

%comspec% /C ""%s_ffmpegx64%" -vsync 0 -extra_hw_frames 2 -hwaccel cuda -hwaccel_output_format cuda -i "%s_source%" -filter_complex "[0:v]split=5[p1_tmp][p2_tmp][p3_tmp][p4_tmp][p5_tmp];[p1_tmp]scale_cuda=480:270[p1];[p2_tmp]scale_cuda=640:360[p2];[p3_tmp]scale_cuda=960:540[p3];[p4_tmp]scale_cuda=960:540[p4];[p5_tmp]scale_cuda=1280:720[p5]" -map "[p1]" -map "[p2]" -map "[p3]" -map "[p4]" -map "[p5]" -map 0:a -c:v h264_nvenc -sc_threshold 0  -force_key_frames "expr:gte(t,n_forced*1)" -profile:v main -preset medium  -c:a aac  -b:a 96k -ar 48000  -af "aresample=async=1:min_hard_comp=0.100000:first_pts=0" -vbsf h264_mp4toannexb -bsf:a aac_adtstoasc -b:v:0 600k -maxrate:v:0 600k -bufsize:v:0 1200k -b:v:1 1100k -maxrate:v:1 1100k -bufsize:v:1 2200k -b:v:2 1700k -maxrate:v:2 1700k -bufsize:v:2 3400k -b:v:3 2200k -maxrate:v:3 2200k -bufsize:v:3 4400k -b:v:4 2800K -maxrate:v:4 2800k -bufsize:v:4 5600k -flags +global_header -f tee "[select=\'v:0,a:0\':f=mp4]C:\location\profile1.mp4|[select=\'v:1,a:0\':f=mp4]C:\location\profile2.mp4|[select=\'v:2,a:0\':f=mp4]C:\location\profile3.mp4|[select=\'v:3,a:0\':f=mp4]C:\location\profile4.mp4|[select=\'v:4,a:0\':f=mp4]C:\location\profile5""
And I get this error:

Code: Select all

Stream mapping:
Stream #0:0 (h264) -> split:default (graph 0)
scale_cuda:default (graph 0) -> Stream #0:0 (h264_nvenc)
scale_cuda:default (graph 0) -> Stream #0:1 (h264_nvenc)
scale_cuda:default (graph 0) -> Stream #0:2 (h264_nvenc)
scale_cuda:default (graph 0) -> Stream #0:3 (h264_nvenc)
scale_cuda:default (graph 0) -> Stream #0:4 (h264_nvenc)
Stream #0:1 -> #0:5 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
Output #0, tee, to '[select='v:0,a:0':f=mp4]C:\location\profile1.mp4|[select='v:1,a:0':f=mp4]C:\location\profile2.mp4|[select='v:2,a:0':f=mp4]C:\location\profile3.mp4|[select='v:3,a:0':f=mp4]C:\location\profile4.mp4|[select='v:4,a:0':f=mp4]C:\location\profile5.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf59.10.100
Stream #0:0: Video: h264 (Main), cuda(progressive), 480x270 [SAR 1:1 DAR 16:9], q=2-31, 600 kb/s, 25 fps, 25 tbn (default)
Metadata:
encoder : Lavc59.14.100 h264_nvenc
Side data:
cpb: bitrate max/min/avg: 600000/0/600000 buffer size: 1200000 vbv_delay: N/A
Stream #0:1: Video: h264 (Main), cuda(progressive), 640x360 [SAR 1:1 DAR 16:9], q=2-31, 1100 kb/s, 25 fps, 25 tbn
Metadata:
encoder : Lavc59.14.100 h264_nvenc
Side data:
cpb: bitrate max/min/avg: 1100000/0/1100000 buffer size: 2200000 vbv_delay: N/A
Stream #0:2: Video: h264 (Main), cuda(progressive), 960x540 [SAR 1:1 DAR 16:9], q=2-31, 1700 kb/s, 25 fps, 25 tbn
Metadata:
encoder : Lavc59.14.100 h264_nvenc
Side data:
cpb: bitrate max/min/avg: 1700000/0/1700000 buffer size: 3400000 vbv_delay: N/A
Stream #0:3: Video: h264 (Main), cuda(progressive), 960x540 [SAR 1:1 DAR 16:9], q=2-31, 2200 kb/s, 25 fps, 25 tbn
Metadata:
encoder : Lavc59.14.100 h264_nvenc
Side data:
cpb: bitrate max/min/avg: 2200000/0/2200000 buffer size: 4400000 vbv_delay: N/A
Stream #0:4: Video: h264 (Main), cuda(progressive), 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 2800 kb/s, 25 fps, 25 tbn
Metadata:
encoder : Lavc59.14.100 h264_nvenc
Side data:
cpb: bitrate max/min/avg: 2800000/0/2800000 buffer size: 5600000 vbv_delay: N/A
Stream #0:5(und): Audio: aac (LC), 48000 Hz, stereo, fltp, 96 kb/s (default)
Metadata:
handler_name : SoundHandler
vendor_id : [0][0][0][0]
encoder : Lavc59.14.100 aac
frame= 1 fps=0.0 q=0.0 q=0.0 q=0.0 q=0.0 q=0.0 size=N/A time=00:00:00.57 bitrate=N/A speed= 7.9x

[h264 @ 00000182dcb65200] No decoder surfaces left
[h264 @ 00000182dcb64a40] No decoder surfaces left
[h264 @ 00000182dcb64e40] No decoder surfaces left
[h264 @ 00000182dcb67180] No decoder surfaces left
[h264 @ 00000182cc354040] No decoder surfaces left
Error while decoding stream #0:0: Invalid data found when processing input
Last message repeated 1 times
[h264 @ 00000182dcb65200] No decoder surfaces left
Error while decoding stream #0:0: Invalid data found when processing input
[h264 @ 00000182dcb64a40] No decoder surfaces left
Error while decoding stream #0:0: Invalid data found when processing input
[h264 @ 00000182dcb64e40] No decoder surfaces left
Impossible to convert between the formats supported by the filter 'Parsed_scale_cuda_5' and the filter 'auto_scale_0'
Error reinitializing filters!
Failed to inject frame into filter network: Function not implemented
Error while processing the decoded data for stream #0:0
[aac @ 00000182cc36d840] Qavg: 200.332
[aac @ 00000182cc36d840] 2 frames left in the queue on closing
Conversion failed!
)
Thanks!
emcodem
Posts: 1811
Joined: Wed Sep 19, 2018 8:11 am

Re: Utlizing NVIDIA DECODER inside the FFMpeg custom encode node

Post by emcodem »

Hey veks,

not that i ever used cuda functionality but i suppose using "hwupload_cuda" might be the solution?
https://stackoverflow.com/questions/520 ... lter-error
emcodem, wrapping since 2009 you got the rhyme?
veks
Posts: 84
Joined: Fri Oct 25, 2019 6:51 am

Re: Utlizing NVIDIA DECODER inside the FFMpeg custom encode node

Post by veks »

Hi,
now I'm trying with this ffmpeg command, but file always goes to root C:\ and filename is the whole UNC path.

Code: Select all

%comspec% /C ""C:\ffmpeg5\bin\ffmpeg.exe" -vsync 0 -hwaccel cuvid -c:v h264_cuvid -i "%s_source%" -filter_complex "[0:v]yadif_cuda,split=5[p1_tmp][p2_tmp][p3_tmp][p4_tmp][p5_tmp];[p1_tmp]scale_cuda=480:270[p1];[p2_tmp]scale_cuda=640:360[p2];[p3_tmp]scale_cuda=960:540[p3];[p4_tmp]scale_cuda=960:540[p4];[p5_tmp]scale_cuda=1280:720[p5]" -map "[p1]" -map "[p2]" -map "[p3]" -map "[p4]" -map "[p5]" -map 0:a -c:v h264_nvenc -sc_threshold 0  -force_key_frames "expr:gte(t,n_forced*1)" -profile:v main -preset medium  -c:a aac  -b:a 96k -ar 48000  -af "aresample=async=1:min_hard_comp=0.100000:first_pts=0" -vbsf h264_mp4toannexb -bsf:a aac_adtstoasc -b:v:0 600k -maxrate:v:0 600k -bufsize:v:0 1200k -b:v:1 1100k -maxrate:v:1 1100k -bufsize:v:1 2200k -b:v:2 1700k -maxrate:v:2 1700k -bufsize:v:2 3400k -b:v:3 2200k -maxrate:v:3 2200k -bufsize:v:3 4400k -b:v:4 2800K -maxrate:v:4 2800k -bufsize:v:4 5600k -flags +global_header -f tee "[select=\'v:0,a:0\':f=mp4]\\192.168.5.55\storage\test_veks_nv_p1.mp4|[select=\'v:1,a:0\':f=mp4]\\192.168.5.55\storage\test_veks_nv_p2.mp4|[select=\'v:2,a:0\':f=mp4]\\192.168.5.55\storage\test_veks_nv_p3.mp4|[select=\'v:3,a:0\':f=mp4]\\192.168.5.55\storage\test_veks_nv_p4.mp4|[select=\'v:4,a:0\':f=mp4]\\192.168.5.55\storage\test_veks_nv_p5.mp4""
Am I'm missing some " or ' ?

Thanks!

EDIT: Added ' on beggining and on the end of each UNC path, and now it works.
Post Reply