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

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

CC BY-SA 4.0
2019-02-12T13:46:09.470Z
`ffmpeg -i input.mp4 -vcodec h264_nvenc -vcodec h264_nvenc -cq 1 -acodec copy 25962-1.mp4` with values 0, 1 and 23 produce the same binary file having bad quality. With 51 file is 3 times smaller and quality is worther. So the parameter is not ignored.
Qwertiy
CC BY-SA 4.0
2019-02-12T14:01:02.267Z
Edited cmd. Values below 26 will produce about the same quality.
Gyan
CC BY-SA 4.0
2019-02-12T14:16:09.667Z
No, still bad quality.
Qwertiy
CC BY-SA 4.0
2019-02-12T14:34:51.873Z
nvenc will not match x264 quality at the same bitrate.
Gyan
CC BY-SA 4.0
2019-02-12T13:40:53.933Z
2019-02-12T13:59:15.477Z
2019-02-12T13:59:15.477Z
Gyan
<p>from reading:</p>
<pre><code>ffmpeg -h encoder=h264_nvenc
</code></pre>
<p>and the nvidia nvenc examples at (<a href="https://devblogs.nvidia.com/nvidia-ffmpeg-transcoding-guide/" rel="nofollow noreferrer">https://devblogs.nvidia.com/nvidia-ffmpeg-transcoding-guide/</a>), I've arrived at:</p>
<pre><code>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
</code></pre>
<p>where:</p>
<pre><code>-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
</code></pre>

CC BY-SA 4.0
2020-06-19T15:41:30.867Z
2020-06-19T15:41:30.867Z
jjisnow
<p>If you don't specify bit rate yourself, FFmpeg will assume a default bit rate of 256 kbit\s, you have to unset it with <code>-b:v 0</code>.</p>

CC BY-SA 4.0
2019-05-08T05:32:49.823Z
The `h264_nvenc` encoder has a default bitrate of 2 mbps. But in any case, the `cq` mode does not look at bitrate.
Gyan
CC BY-SA 4.0
2019-05-08T07:39:07.860Z
Can you show the full command, please?
Qwertiy
CC BY-SA 4.0
2019-05-08T04:31:15.933Z
2019-05-08T04:31:15.933Z
Awa
<p>Encoding on CPU can be done via:</p>

<pre><code>ffmpeg -i input.mp4 -vcodec h264 -crf 23 -acodec copy h264.mp4
</code></pre>

<p>GPU's alternative for the codec is <code>h264_nvenc</code>. How can I pass the same options to it?</p>

<hr>

<p>I googled and came to following command:</p>

<pre><code>ffmpeg -i input.mp4 -vcodec h264_nvenc -rc constqp -qp 23 -acodec copy h264_nvenc.mp4
</code></pre>

<p>But the file I get is much larger. And with other options quality is much worther.</p>

<p>PS: <a href="//ru.stackoverflow.com/q/943877/178988">Same question in Russian.</a></p>

<ffmpeg><h.264><nvidia>
Configure CQP (CRF) for h264_nvenc
Qwertiy
# Configure CQP (CRF) for h264_nvenc

(Asked by: username_0 on 2019-02-12)

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.

**Tags:** ffmpeg, h.264, nvidia


---

## 3 answers

### Answer by username_1 on 2019-02-12. Score: 3

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.

> **Comments:**
> **username_0**: `ffmpeg -i input.mp4 -vcodec h264_nvenc -vcodec h264_nvenc -cq 1 -acodec copy 25962-1.mp4` with values 0, 1 and 23 produce the same binary file having bad quality. With 51 file is 3 times smaller and quality is worther. So the parameter is not ignored.  
> **username_1**: Edited cmd. Values below 26 will produce about the same quality.  
> **username_0**: No, still bad quality.  
> **username_1**: nvenc will not match x264 quality at the same bitrate.  

---

### Answer by username_2 on 2020-06-19. Score: 2

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 username_1
-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


---

### Answer by username_3 on 2019-05-08. Score: 1

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

> **Comments:**
> **username_1**: The `h264_nvenc` encoder has a default bitrate of 2 mbps. But in any case, the `cq` mode does not look at bitrate.  
> **username_0**: Can you show the full command, please?  

---

