Hi,
if QSV is enabled on a FFAStrans host, will FFAStrans ffmpeg custom node take use of it, or it will only use software decoding and QSV encoding (if set in ffmpeg command)?
Thanks!
Utilizing Intel QSV as decoder and encoder
Re: Utilizing Intel QSV as decoder and encoder
Hi veks,
Using custom ffmpeg processor, you cannot specify any input options, so this one will never decode using any hardware decoder. You need to use commandline processor for this. (which is what i prefer anyway, custom ffmpeg has no benefit for me over commandline proc AND it is harder to use and to debug). In general decoding on hardware is considered to be relatively unstable, it can happen that the decoding seems to work but the decoded picture contents are destroyed. Such issues are not easy to detect which leads us to stick to CPU decoding if we don't know the exact details of the input stream and we can therefore guarantee the input stream is compatible to the hardware decoder.
Regarding encoding:
As you know ffastrans itself has no knowledge about all this. So you'd need to check if ffmpeg is using the hardware qsv manually by just doing a transcode like
As i dont have any machine where it runs with software h264_qsv, i cannot tell you how to determine if software or hardware encoding is used, except you check in taskmanager cpu/gpu (video encoder) utilisation.
As you can see, h264_qsv looks like this, hevc_qsv would burn some more percent of gpu utilisation (funny enough it says it uses GPU "3d" engine even if it uses the video encode engine).
Using custom ffmpeg processor, you cannot specify any input options, so this one will never decode using any hardware decoder. You need to use commandline processor for this. (which is what i prefer anyway, custom ffmpeg has no benefit for me over commandline proc AND it is harder to use and to debug). In general decoding on hardware is considered to be relatively unstable, it can happen that the decoding seems to work but the decoded picture contents are destroyed. Such issues are not easy to detect which leads us to stick to CPU decoding if we don't know the exact details of the input stream and we can therefore guarantee the input stream is compatible to the hardware decoder.
Regarding encoding:
As you know ffastrans itself has no knowledge about all this. So you'd need to check if ffmpeg is using the hardware qsv manually by just doing a transcode like
Code: Select all
%path_to_ffastrans%\Processors\ffmpeg\x86\ffmpeg.exe -f lavfi -i mandelbrot -c:v h264_qsv c:\temp\out.mp4
As you can see, h264_qsv looks like this, hevc_qsv would burn some more percent of gpu utilisation (funny enough it says it uses GPU "3d" engine even if it uses the video encode engine).
emcodem, wrapping since 2009 you got the rhyme?
Re: Utilizing Intel QSV as decoder and encoder
While I got QSV working on my machine when running it through CMD command manually.
I can't get that same command working via command node in FFAStrans.
No idea why.
Example of the command:
FFAStrans command just exits, and I don't get any debug log from ffmpeg. So no idea what's going on.
As I said, manually running that command in cmd works fine.
Also I've tried with built-in ffmpeg, same.
Thanks!
I can't get that same command working via command node in FFAStrans.
No idea why.
Example of the command:
Code: Select all
%comspec% /C ""C:\ffmpeg5\bin\ffmpeg.exe" -loglevel debug -hwaccel qsv -c:v h264_qsv -i "%s_source%" -c:v h264_qsv -f mp4 'C:\FFAStrans_Farm_mediacache\Profiles\%s_original_name%_1.mp4'"
As I said, manually running that command in cmd works fine.
Also I've tried with built-in ffmpeg, same.
Thanks!
Re: Utilizing Intel QSV as decoder and encoder
Using your command unmodified (besides output path), submitting a file and using webinterface to see the output of the spawned command line revealed this:
After changing the single quotes to double, it ran but it didnt show any gpu utilisation.
I needed to alter your command to this in order to get 90% GPU utilisation:
Note that i removed also -loglevel debug just in order to remove noise and also i change the ffmpeg path to the one that comes with ffastrans. You don't need a custom build just for utilizing QSV or NVENC, it is contained in every standard build these days. Also i added -y as usual in automation in order to avoid potentially forever hanging ffmpeg, waiting for me to confirm overwrite of the output file.
I believe the keys were:
-) change from single quotes to double
-) remove -hwaccel qsv
Did you manage to get nvenc and qsv running on the same machine at the same time?
After changing the single quotes to double, it ran but it didnt show any gpu utilisation.
I needed to alter your command to this in order to get 90% GPU utilisation:
Code: Select all
%comspec% /C ""%s_ffmpeg%" -c:v h264_qsv -i "%s_source%" -c:v h264_qsv -f mp4 -y "C:\temp\%s_original_name%_1.mp4""
I believe the keys were:
-) change from single quotes to double
-) remove -hwaccel qsv
Did you manage to get nvenc and qsv running on the same machine at the same time?
emcodem, wrapping since 2009 you got the rhyme?
Re: Utilizing Intel QSV as decoder and encoder
Thanks, this works!emcodem wrote: ↑Wed Mar 30, 2022 7:12 am Using your command unmodified (besides output path), submitting a file and using webinterface to see the output of the spawned command line revealed this:
veks_err.png
After changing the single quotes to double, it ran but it didnt show any gpu utilisation.
I needed to alter your command to this in order to get 90% GPU utilisation:
Note that i removed also -loglevel debug just in order to remove noise and also i change the ffmpeg path to the one that comes with ffastrans. You don't need a custom build just for utilizing QSV or NVENC, it is contained in every standard build these days. Also i added -y as usual in automation in order to avoid potentially forever hanging ffmpeg, waiting for me to confirm overwrite of the output file.Code: Select all
%comspec% /C ""%s_ffmpeg%" -c:v h264_qsv -i "%s_source%" -c:v h264_qsv -f mp4 -y "C:\temp\%s_original_name%_1.mp4""
I believe the keys were:
-) change from single quotes to double
-) remove -hwaccel qsv
Did you manage to get nvenc and qsv running on the same machine at the same time?
Also, yes, I'm running nvdec, nvenc and qsv on the same machine.
Tho, when decoder is nvdec, quality for lower profiles, from let's 480p and under is really really bad compared to those that are being decoded via SW and encoded via NVENC. Or totally decoded and encoded via QSV.
Sure in a scenario with SW decoder + NV encoder I get far more speed. But then GPU and CPU is at almost 100% when encoding 6 profiles at the same time. At about 200-270 fps.
Re: Utilizing Intel QSV as decoder and encoder
When I add the flag for scaling, then it doesn't work:
-vf scale_qsv=480:270
example:
It works in CMD directly.
EDIT: I think that for QSV scaling to work -hwaccel qsv flag needs to be added... But it still doesn't work and I get this error:
Same command works in CMD directly...
Any idea why?
In FFAStrans webgui I can see the ffmpeg error (while in direct CMD is OK and encoding continues):
-vf scale_qsv=480:270
example:
Code: Select all
%comspec% /C ""%s_ffmpeg%" -c:v h264_qsv -i "C:\FFAStrans_Farm_mediacache\%s_original_name%.%s_original_ext%" -vf scale_qsv=480:270 -c:v h264_qsv -f mp4 -y "C:\FFAStrans_Farm_mediacache\Profiles\%s_original_name%_1.mp4""
EDIT: I think that for QSV scaling to work -hwaccel qsv flag needs to be added... But it still doesn't work and I get this error:
Code: Select all
[h264_qsv @ 01f5eb40] No device available for decoder: device type qsv needed for codec h264_qsv.
Any idea why?
In FFAStrans webgui I can see the ffmpeg error (while in direct CMD is OK and encoding continues):
Code: Select all
WARNING: defaulting child_device_type to AV_HWDEVICE_TYPE_DXVA2 for compatibility with old commandlines. This behaviour will be removed in the future. Please explicitly set device type via "-init_hw_device" option.
[AVHWDeviceContext @ 00000225b3a444c0] Failed to create Direct3D device
Device creation failed: -1313558101.
[h264_qsv @ 00000225b3815ec0] No device available for decoder: device type qsv needed for codec h264_qsv.
Stream mapping:
Stream #0:0 -> #0:0 (h264 (h264_qsv) -> h264 (h264_qsv))
Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Device setup failed for decoder on input stream #0:0 : Unknown error occurred
)
Re: Utilizing Intel QSV as decoder and encoder
Just to finish that topic, after some private messaging, we came to the conclusion that quicksync can or does require a "user to be logged on" and/or a "display to be physically connected". This is the reason why it works when running on cmd prompt but not when ffastrans executes it (installed as background service).
Unfortunately there is currently no solution known to workaround this, so i guess if you want to use quicksync scaling and/or encoding, you must run ffastrans as application instead of as service.
emcodem, wrapping since 2009 you got the rhyme?