Hello. I found this ffmpeg code to downscale 1080p to 720p:
It should have good quality in small size. It use better scaling method than default.Code:for %%f in (*.mkv) do ( echo Processing %%f... ffmpeg -i "%%f" -c:v libx264 -crf 21 -level 3.1 -preset slow -tune film -filter:v scale=-1:720 -sws_flags lanczos -c:a copy -c:s copy "output\%%f.mkv" )
But I have not powerful CPU and good GPU.
So, how to modify this command to use NVIDIA CUDA instead?
I found something like that but not sure how to add tune film and sws_flags lanczos
Code:ffmpeg -hwaccel cuda -hwaccel_output_format cuda -i "%%f" " -c:a copy -c:s copy -vf "scale_cuda=-1:720" -c:v h264_nvenc "output_file.mp4"
+ Reply to Thread
Results 1 to 7 of 7
-
-
-
Win10 64bit
FFMPEG from here https://www.gyan.dev/ffmpeg/builds/
With this command:
Code:ffmpeg -y -hwaccel cuda -hwaccel_output_format cuda -i "%%f" -c:v h264_nvenc -profile:v high -level 4.0 -tune hq -preset p7 -vf "scale_cuda=-1:720" -b:v 0 -sws_flags lanczos -cq 27 -c:a copy -c:s copy "output\%%f.mkv"
I found that nvenc is ignoring crf 19
and I should use cq to set quality (crf 19 = cq from 23 to 25)
And I can't find anything what is is "-tune hq" if I use "-tune film" I get error
And I don't know -sws_flags lanczos is used because I have no fps drop when using that
Edit:
Also tried that:
HTML Code:ffmpeg -y -i "%%f" -c:v h264_nvenc -cq 25 -level 3.1 -preset slow -tune hq -filter:v scale=-1:720 -sws_flags lanczos -c:a copy -c:s copy "output\%%f.mkv"
Last edited by SmurfRecorder; 17th Dec 2024 at 08:44.
-
try to follow https://docs.nvidia.com/video-technologies/video-codec-sdk/12.2/ffmpeg-with-nvidia-gpu/index.html
Based on above NVidia guide seem ffmpeg commandline should look like this:
Code:ffmpeg -y -vsync 0 -hwaccel cuda -hwaccel_output_format cuda -i input.mp4 -vf scale_cuda=1280:720 -vf scale_npp=1280:720 -c:a copy -c:v h264_nvenc -preset p7 -tune hq -b:v 5M -bufsize 5M -maxrate 10M -qmin 0 -g 250 -bf 3 -b_ref_mode middle -temporal-aq 1 -rc-lookahead 32 -i_qfactor 0.75 -b_qfactor 1.1 output.mp4
eitherCode:-vf scale_cuda=1280:720
Code:-vf scale_npp=1280:720
Last edited by pandy; 17th Dec 2024 at 17:16.
-
Pandy's command line encodes at about 550 fps on my RTX 4060 (1080p to 720p). Just use -qp N instead of -b:v 5M if you want "quality" based encoding.
Last edited by jagabo; 17th Dec 2024 at 20:59.
-
Of course there is possibility to tweak both resizers (default resize algorithm seem to be bicubic) also there is possibility to use libplacebo with very high quality resize filters and/or custom shaders - how this impact performance is unknown to me - my last NVidia card was ancient Geforce 4 440MX (over 20 years ago).
Similar Threads
-
ffmpeg transcode H.265 to H.264 by Nvidia CUDA error
By slick zheng in forum Video ConversionReplies: 18Last Post: 4th Aug 2023, 00:37 -
How To Downscale 4K 2160p HEVC 10 bit Video To 2K 1080p AVC 10bit
By LouieChuckyMerry in forum Video ConversionReplies: 32Last Post: 26th May 2023, 02:07 -
will there be quality loss if i convert from 1080p to 720p
By cns00 in forum Video ConversionReplies: 9Last Post: 25th May 2022, 01:01 -
Intel QSV VS Nvidia CUDA
By BlurayHD in forum Newbie / General discussionsReplies: 34Last Post: 18th Oct 2020, 03:26 -
Best Way To Downscale 1080p 30fps Sports Video to 720p for Bluray?
By AndersonJames in forum RestorationReplies: 10Last Post: 18th Jun 2020, 13:25