diff --git a/docs/configuration.md b/docs/configuration.md index 97f08576cd1..d41202aece4 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -2788,6 +2788,40 @@ editing the `conf` file in a text editor. Use the examples as reference. +### amd_max_au_size + + + + + + + + + + + + + + +
Description + Maximum Access Unit (frame) size for rate control, in bits. When set, the encoder + will cap the maximum encoded frame size. This prevents oversized frames from exceeding + FEC shard limits (DATA_SHARDS_MAX=255), which otherwise causes FEC to be skipped for + those frames. This is especially important for Wi-Fi streaming where packet loss on + large unprotected frames leads to dropped frames and stuttering. + @note{This option only applies to H.264 and HEVC when using amdvce [encoder](#encoder). + AV1 does not support this option.} + @note{Works with all rate control modes (CQP, CBR, VBR). Most beneficial with CQP + where frame sizes are otherwise unbounded.} + @note{Value is in bits. To calculate: (target_bitrate_mbps / fps / 1.2) × 1000000, + where 1.2 accounts for ~20% FEC overhead. Examples: 800000 for ~50 Mbps at 60fps, + 1600000 for ~100 Mbps at 60fps, 400000 for ~50 Mbps at 120fps.} +
Default@code{} + + @endcode
Example@code{} + amd_max_au_size = 800000 + @endcode
+ ## VideoToolbox Encoder ### vt_coder diff --git a/src/config.cpp b/src/config.cpp index 47475a04b4d..17882839435 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -472,6 +472,7 @@ namespace config { (int) amd::quality_av1_e::balanced, // quality (av1) 0, // preanalysis 1, // vbaq + {}, // max_au_size (disabled by default) (int) amd::coder_e::_auto, // coder }, // amd @@ -1129,6 +1130,7 @@ namespace config { bool_f(vars, "amd_preanalysis", (bool &) video.amd.amd_preanalysis); bool_f(vars, "amd_vbaq", (bool &) video.amd.amd_vbaq); bool_f(vars, "amd_enforce_hrd", (bool &) video.amd.amd_enforce_hrd); + int_f(vars, "amd_max_au_size", video.amd.amd_max_au_size); int_f(vars, "vt_coder", video.vt.vt_coder, vt::coder_from_view); int_f(vars, "vt_software", video.vt.vt_allow_sw, vt::allow_software_from_view); diff --git a/src/config.h b/src/config.h index 6e4f001b707..01f55e42e8f 100644 --- a/src/config.h +++ b/src/config.h @@ -66,6 +66,7 @@ namespace config { std::optional amd_quality_av1; std::optional amd_preanalysis; std::optional amd_vbaq; + std::optional amd_max_au_size; int amd_coder; } amd; diff --git a/src/video.cpp b/src/video.cpp index 6b2b635277c..c5326c6d414 100644 --- a/src/video.cpp +++ b/src/video.cpp @@ -776,6 +776,7 @@ namespace video { {"usage"s, &config::video.amd.amd_usage_hevc}, {"vbaq"s, &config::video.amd.amd_vbaq}, {"enforce_hrd"s, &config::video.amd.amd_enforce_hrd}, + {"max_au_size"s, &config::video.amd.amd_max_au_size}, {"level"s, [](const config_t &cfg) { auto size = cfg.width * cfg.height; // For 4K and below, try to use level 5.1 or 5.2 if possible @@ -813,6 +814,7 @@ namespace video { {"usage"s, &config::video.amd.amd_usage_h264}, {"vbaq"s, &config::video.amd.amd_vbaq}, {"enforce_hrd"s, &config::video.amd.amd_enforce_hrd}, + {"max_au_size"s, &config::video.amd.amd_max_au_size}, }, {}, // SDR-specific options {}, // HDR-specific options diff --git a/src_assets/common/assets/web/config.html b/src_assets/common/assets/web/config.html index b391e3e7470..afbdb2f6ddf 100644 --- a/src_assets/common/assets/web/config.html +++ b/src_assets/common/assets/web/config.html @@ -314,6 +314,7 @@

{{ $t('config.configuration') }}

"amd_preanalysis": "disabled", "amd_vbaq": "enabled", "amd_coder": "auto", + "amd_max_au_size": "", }, }, { diff --git a/src_assets/common/assets/web/configs/tabs/encoders/AmdAmfEncoder.vue b/src_assets/common/assets/web/configs/tabs/encoders/AmdAmfEncoder.vue index 1da4999942c..738e2767258 100644 --- a/src_assets/common/assets/web/configs/tabs/encoders/AmdAmfEncoder.vue +++ b/src_assets/common/assets/web/configs/tabs/encoders/AmdAmfEncoder.vue @@ -56,6 +56,14 @@ const config = ref(props.config) v-model="config.amd_enforce_hrd" default="false" > + + +
+ + +
{{ $t('config.amd_max_au_size_desc') }}
+
diff --git a/src_assets/common/assets/web/public/assets/locale/en.json b/src_assets/common/assets/web/public/assets/locale/en.json index a647f446b90..0b2448cd2e7 100644 --- a/src_assets/common/assets/web/public/assets/locale/en.json +++ b/src_assets/common/assets/web/public/assets/locale/en.json @@ -109,6 +109,8 @@ "amd_coder_desc": "Allows you to select the entropy encoding to prioritize quality or encoding speed. H.264 only.", "amd_enforce_hrd": "AMF Hypothetical Reference Decoder (HRD) Enforcement", "amd_enforce_hrd_desc": "Increases the constraints on rate control to meet HRD model requirements. This greatly reduces bitrate overflows, but may cause encoding artifacts or reduced quality on certain cards.", + "amd_max_au_size": "AMF Max AU Size (bits)", + "amd_max_au_size_desc": "Maximum Access Unit (frame) size in bits. Empty or -1 disables. Prevents oversized frames from exceeding FEC limits on Wi-Fi. H.264 and HEVC only. Formula: (target_bitrate_mbps / fps / 1.2) * 1000000. Example at 50 Mbps 60fps: (50/60/1.2)*1000000 = 694444. Recommended: 800000 for ~50 Mbps Wi-Fi.", "amd_preanalysis": "AMF Preanalysis", "amd_preanalysis_desc": "This enables rate-control preanalysis, which may increase quality at the expense of increased encoding latency.", "amd_quality": "AMF Quality",