Skip to content

Commit a578d84

Browse files
committed
lavc vpx: set rc_lookahead to 0
to reduce latency
1 parent 2dd9b39 commit a578d84

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

src/video_compress/libavcodec.cpp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,7 @@ static enum AVPixelFormat get_first_matching_pix_fmt(list<enum AVPixelFormat>
713713
}
714714

715715
template<typename T>
716-
static inline void check_av_opt_set(void *priv_data, const char *key, T val) {
716+
static inline void check_av_opt_set(void *priv_data, const char *key, T val, const char *desc = nullptr) {
717717
int ret = 0;
718718
string val_str;
719719
if constexpr (std::is_same_v<T, int>) {
@@ -724,7 +724,7 @@ static inline void check_av_opt_set(void *priv_data, const char *key, T val) {
724724
val_str = val;
725725
}
726726
if (ret != 0) {
727-
string err = string(MOD_NAME) + "Unable to set " + key + " to " + val_str;
727+
string err = string(MOD_NAME) + "Unable to set " + (desc ? desc : key) + " to " + val_str;
728728
print_libav_error(LOG_LEVEL_WARNING, err.c_str(), ret);
729729
}
730730
}
@@ -2000,13 +2000,9 @@ static void setparam_vp8_vp9(AVCodecContext *codec_ctx, struct setparam_param *p
20002000
{
20012001
codec_ctx->rc_buffer_size = codec_ctx->bit_rate / param->desc.fps;
20022002
//codec_ctx->rc_buffer_aggressivity = 0.5;
2003-
if (av_opt_set(codec_ctx->priv_data, "deadline", "realtime", 0) != 0) {
2004-
log_msg(LOG_LEVEL_WARNING, "[lavc] Unable to set deadline.\n");
2005-
}
2006-
2007-
if (av_opt_set(codec_ctx->priv_data, "cpu-used", "8", 0)) {
2008-
log_msg(LOG_LEVEL_WARNING, "[lavc] Unable to set quality/speed ratio modifier.\n");
2009-
}
2003+
check_av_opt_set<const char *>(codec_ctx->priv_data, "deadline", "realtime");
2004+
check_av_opt_set<int>(codec_ctx->priv_data, "cpu-used", 8, "quality/speed ration modifier");
2005+
check_av_opt_set<int>(codec_ctx->priv_data, "rc_lookahead", 0);
20102006
}
20112007

20122008
static void libavcodec_check_messages(struct state_video_compress_libav *s)

0 commit comments

Comments
 (0)