AnswerBun.com

Configure CQP (CRF) for h264_nvenc

Video Production Asked on October 28, 2021

Encoding on CPU can be done via:

ffmpeg -i input.mp4 -vcodec h264 -crf 23 -acodec copy h264.mp4

GPU’s alternative for the codec is h264_nvenc. How can I pass the same options to it?


I googled and came to following command:

ffmpeg -i input.mp4 -vcodec h264_nvenc -rc constqp -qp 23 -acodec copy h264_nvenc.mp4

But the file I get is much larger. And with other options quality is much worther.

PS: Same question in Russian.

3 Answers

from reading:

ffmpeg -h encoder=h264_nvenc

and the nvidia nvenc examples at (https://devblogs.nvidia.com/nvidia-ffmpeg-transcoding-guide/), I've arrived at:

ffmpeg -vsync 0 -hwaccel cuvid -c:v h264_cuvid -i test_input.mp4 -c:a copy -c:v h264_nvenc -b:v 0 -cq 1 test3.mp4

where:

-b:v 0 over-rides the default 2mbps bitrate as noted by Gyan
-cq 1 means target quality level 1 (highest)
 range of 0-51. 
 0 means automatic (in my case around 15mbps)
 1 gives about 15mbps, 26 results in around 5mbps, 51 results in 0.5mbps

Answered by jjisnow on October 28, 2021

If you don't specify bit rate yourself, FFmpeg will assume a default bit rate of 256 kbits, you have to unset it with -b:v 0.

Answered by Awa on October 28, 2021

CRF != CQP. The former may have variable QP but tries to maintain quality. CQP is a cruder form of rate-control.

For nvenc, use -rc vbr_hq -qmin 0 and add -cq X where X sets a quality level; range is 0-51. Smaller is better.

Answered by Gyan on October 28, 2021

Add your own answers!

Related Questions

Lighting a chalkboard

3  Asked on October 28, 2021 by algeboy

 

Scale video without keeping aspect ratio in ffmpeg

1  Asked on October 28, 2021 by bakhanov-a

   

ffmpeg amix filter command execution never stops

1  Asked on October 28, 2021 by khawar-raza

   

Configure CQP (CRF) for h264_nvenc

3  Asked on October 28, 2021

     

Easiest way to create video with multiple videos on loop

1  Asked on October 28, 2021 by navy-seal

 

Increase Volume of a specific mxf channel with ffmpeg

1  Asked on October 28, 2021 by user26625

 

Unsupported video driver on bootcamp

1  Asked on October 28, 2021

       

Issue with sony vegas rendering small parts of video

1  Asked on October 28, 2021 by andrei-irimie

   

Ask a Question

Get help from others!

© 2022 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP