Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]Default -crf flag is not suitable for h264_nvenc #82

Open
nkh0472 opened this issue Apr 16, 2021 · 1 comment
Open

[BUG]Default -crf flag is not suitable for h264_nvenc #82

nkh0472 opened this issue Apr 16, 2021 · 1 comment

Comments

@nkh0472
Copy link
Contributor

nkh0472 commented Apr 16, 2021

No description provided.

@nkh0472 nkh0472 changed the title [BUG]Default --crf is [BUG]Default --crf is not work on h264_nvenc Apr 16, 2021
@nkh0472 nkh0472 changed the title [BUG]Default --crf is not work on h264_nvenc [BUG]Default -crf flag is not suitable for h264_nvenc Apr 16, 2021
@nkh0472
Copy link
Contributor Author

nkh0472 commented Apr 16, 2021

In Video-Encoding section, when change Quality option from "Auto" to any other option such like "Ultra", the default bitrate control method is "CRF", whether or not the nvenc encoder is enabled.
However, h264_nvenc is not support --crf flag according to ffmpeg --help encoder=nvenc.
Thus when hit Convert button, the ffmpeg will give an error as below and exit.

Codec AVOption crf (Select the quality for constant quality mode) specified for output file #0 (X:\output.mp4) has not been used for any stream. The most likely reason is either wrong type (e.g. a video option with no video streams) or that it is a private option of some encoder which was not actually used for any stream.
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> h264 (h264_nvenc))
Press [q] to stop, [?] for help
[h264_nvenc @ 000001ea39c007c0] Specified rc mode is deprecated.
[h264_nvenc @ 000001ea39c007c0] Use -rc constqp/cbr/vbr, -tune and -multipass instead.
[h264_nvenc @ 000001ea39c007c0] InitializeEncoder failed: invalid param (8): Presets P1 to P7 are not supported with older 2 Pass RC Modes(CBR_HQ, VBR_HQ) and cbr lowdelay.
Enable NV_ENC_RC_PARAMS::multiPass flag for two pass encoding a
Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
Conversion failed!

Instead, we can use -cq:v number to replace -crf number when h264_nvenc is enabled.
-cq <float> E..V....... Set target quality level (0 to 51, 0 means automatic) for constant quality mode in VBR rate control (from 0 to 51) (default 0)
And use optional flags -maxrate:v number -bufsize number to constrain bitrate.


However there is another bug:
In Video-Encoding section, when set Quality to Custom, set Pass to 1 Pass or 2 Pass, the Bit Rate values disappear in script. That means even I input numbers in Bit Rate Min Rate and other 2 blanks, the script will still looks like:

......
-c:v h264_nvenc 
-preset slow 
-pix_fmt yuv420p 
-vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" 
-map 0:v:0?
......

Only when using default quality options like High, the script works correctly:

......
-c:v h264_nvenc 
-preset slow -q:v 2500K 
-pix_fmt yuv420p 
-vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" 
-map 0:v:0? 
......

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant