fix(h264_nvenc): fixing crf handling for h264_nvenc

This commit is contained in:
CarolinePascal
2026-05-13 18:09:48 +02:00
parent 246d7e1dea
commit 60b05efb4f
3 changed files with 11 additions and 11 deletions
+2 -2
View File
@@ -80,11 +80,11 @@ All flags below are prefixed with `--dataset.camera_encoder.` on the CLI.
How each field is forwarded to FFmpeg after `vcodec` resolution, via `get_codec_options()`. Only fields on `camera_encoder` are listed here (no global thread / queue flags). How each field is forwarded to FFmpeg after `vcodec` resolution, via `get_codec_options()`. Only fields on `camera_encoder` are listed here (no global thread / queue flags).
| Resolved `vcodec` | Quality from `crf` | `preset` | `fast_decode` | | Resolved `vcodec` | Quality from `crf` | `preset` | `fast_decode` |
| ---------------------------------------- | --------------------------- | -------- | ------------------------------------------ | | ---------------------------------------- | -------------------------- | -------- | ------------------------------------------ |
| `libsvtav1` | `crf` | `preset` | `svtav1-params` includes `fast-decode=0…2` | | `libsvtav1` | `crf` | `preset` | `svtav1-params` includes `fast-decode=0…2` |
| `h264`, `hevc` (software) | `crf` | `preset` | `tune=fastdecode` if `fast_decode > 0` | | `h264`, `hevc` (software) | `crf` | `preset` | `tune=fastdecode` if `fast_decode > 0` |
| `h264_videotoolbox`, `hevc_videotoolbox` | `q:v` (derived from `crf`) | — | — | | `h264_videotoolbox`, `hevc_videotoolbox` | `q:v` (derived from `crf`) | — | — |
| `h264_nvenc`, `hevc_nvenc` | `rc=constqp` + `qp` ← `crf` | `preset` | — | | `h264_nvenc`, `hevc_nvenc` | `rc` = `0`, `qp` ← `crf` | `preset` | — |
| `h264_vaapi` | `qp` ← `crf` | — | — | | `h264_vaapi` | `qp` ← `crf` | — | — |
| `h264_qsv` | `global_quality` ← `crf` | `preset` | — | | `h264_qsv` | `global_quality` ← `crf` | `preset` | — |
+1 -1
View File
@@ -210,7 +210,7 @@ class VideoEncoderConfig:
if self.crf is not None: if self.crf is not None:
opts["q:v"] = max(1, min(100, 100 - self.crf * 2)) opts["q:v"] = max(1, min(100, 100 - self.crf * 2))
elif self.vcodec in ("h264_nvenc", "hevc_nvenc"): elif self.vcodec in ("h264_nvenc", "hevc_nvenc"):
opts["rc"] = "constqp" opts["rc"] = 0
set_if("qp", self.crf) set_if("qp", self.crf)
set_if("preset", self.preset) set_if("preset", self.preset)
elif self.vcodec == "h264_vaapi": elif self.vcodec == "h264_vaapi":
+2 -2
View File
@@ -90,10 +90,10 @@ class TestCodecOptions:
def test_nvenc_options(self): def test_nvenc_options(self):
cfg = VideoEncoderConfig(vcodec="h264_nvenc", g=2, crf=25, preset=None) cfg = VideoEncoderConfig(vcodec="h264_nvenc", g=2, crf=25, preset=None)
opts = cfg.get_codec_options() opts = cfg.get_codec_options()
assert opts["rc"] == "constqp" assert opts["rc"] == 0
assert opts["qp"] == 25 assert opts["qp"] == 25
assert "crf" not in opts assert "crf" not in opts
assert "g" not in opts assert opts["g"] == 2
@_require_encoder("h264_vaapi") @_require_encoder("h264_vaapi")
def test_vaapi_options(self): def test_vaapi_options(self):