From e20ce512fb94e021f0ca497ba64b3efdde571386 Mon Sep 17 00:00:00 2001 From: Martin Pulec Date: Tue, 9 Jul 2024 15:03:08 +0200 Subject: [PATCH] vcomp/lavc: unset svtav1 pred-struct=1 with bitrate User may be tempted to set the bitrate although CRF is now default, so unset pred-struct (because it won't work with current ffmpeg/libxsvtav1). But issue a (serious) warning in this case. --- src/video_compress/libavcodec.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/video_compress/libavcodec.cpp b/src/video_compress/libavcodec.cpp index 337f7b3f1..f1ed101ba 100644 --- a/src/video_compress/libavcodec.cpp +++ b/src/video_compress/libavcodec.cpp @@ -789,7 +789,8 @@ static enum AVPixelFormat get_first_matching_pix_fmt(list::c template static inline bool check_av_opt_set(void *priv_data, const char *key, T val, const char *desc = nullptr) { string val_str; - if constexpr (std::is_same_v) { + if constexpr (std::is_same_v || + std::is_same_v) { val_str = val; } else { val_str = to_string(val); @@ -1948,8 +1949,17 @@ static void configure_svt(AVCodecContext *codec_ctx, struct setparam_param *para preset); #if LIBAVCODEC_VERSION_INT > AV_VERSION_INT(59, 21, 100) //pred-struct=1 is low-latency mode - check_av_opt_set(codec_ctx->priv_data, "svtav1-params", - "pred-struct=1:fast-decode=1:tile-columns=2:tile-rows=2"); + char params[STR_LEN] = "pred-struct=1:"; + if (param->requested_bitrate > 0) { + params[0] = '\0'; // do not set pred-struct for VBR + MSG(WARNING, "Bitrate setting for SVT AV1 is not " + "recommended since it increases latency, " + "use CRF/CQP if possible\n"); + } + snprintf(params + strlen(params), + sizeof params - strlen(params), "%s", + "fast-decode=1:tile-columns=2:tile-rows=2"); + check_av_opt_set(codec_ctx->priv_data, "svtav1-params", params); #else // tile_columns and tile_rows are log2 values for (auto const &val : { "tile_columns", "tile_rows" }) {