VideoHelp Forum




+ Reply to Thread
Results 1 to 7 of 7
  1. Hello. I found this ffmpeg code to downscale 1080p to 720p:
    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"
    )
    It should have good quality in small size. It use better scaling method than default.

    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"
    Quote Quote  
  2. Originally Posted by SmurfRecorder View Post
    Hello. I found this ffmpeg code to downscale 1080p to 720p:
    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"
    )
    It should have good quality in small size. It use better scaling method than default.

    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"
    Can I ask which OS and 32 or 64bit you use and which Nvidia GPU?
    Quote Quote  
  3. 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 have about 200fps with Nvidia 1050Ti while with CPU i have under 20fps

    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"
    It's encoding with about 150fps
    Last edited by SmurfRecorder; 17th Dec 2024 at 08:44.
    Quote Quote  
  4. 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
    Use one (NVidia seem to accept both) of bellow HW accelerated resizers:


    either
    Code:
    -vf scale_cuda=1280:720
    or
    Code:
    -vf scale_npp=1280:720
    Last edited by pandy; 17th Dec 2024 at 17:16.
    Quote Quote  
  5. 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.
    Quote Quote  
  6. 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).
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!