mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-09-13 02:54:26 +08:00
refactor: 降低 hwcodec 探测日志噪音
This commit is contained in:
@@ -120,7 +120,8 @@ bool set_lantency_free(void *priv_data, const std::string &name) {
|
||||
}
|
||||
if (name.find("amf") != std::string::npos) {
|
||||
if ((ret = av_opt_set(priv_data, "query_timeout", "1000", 0)) < 0) {
|
||||
LOG_WARN(std::string("amf query_timeout option is unavailable, ret = ") + av_err2str(ret));
|
||||
LOG_DEBUG(std::string("amf query_timeout option is unavailable, ret = ") +
|
||||
av_err2str(ret));
|
||||
}
|
||||
}
|
||||
if (name.find("qsv") != std::string::npos) {
|
||||
@@ -139,7 +140,8 @@ bool set_lantency_free(void *priv_data, const std::string &name) {
|
||||
if (name.find("rkmpp") != std::string::npos) {
|
||||
// Set async_depth to 1 for minimal buffering (0 = synchronous, higher = more buffering)
|
||||
if ((ret = av_opt_set(priv_data, "async_depth", "1", 0)) < 0) {
|
||||
LOG_WARN(std::string("rkmpp set async_depth failed, ret = ") + av_err2str(ret));
|
||||
LOG_DEBUG(std::string("rkmpp async_depth option is unavailable, ret = ") +
|
||||
av_err2str(ret));
|
||||
// Not fatal - older FFmpeg versions may not support this option
|
||||
}
|
||||
}
|
||||
@@ -147,11 +149,13 @@ bool set_lantency_free(void *priv_data, const std::string &name) {
|
||||
if (name.find("v4l2m2m") != std::string::npos) {
|
||||
// Minimize number of output buffers for lower latency
|
||||
if ((ret = av_opt_set_int(priv_data, "num_output_buffers", 4, 0)) < 0) {
|
||||
LOG_WARN(std::string("v4l2m2m set num_output_buffers failed, ret = ") + av_err2str(ret));
|
||||
LOG_DEBUG(std::string("v4l2m2m num_output_buffers option is unavailable, ret = ") +
|
||||
av_err2str(ret));
|
||||
// Not fatal
|
||||
}
|
||||
if ((ret = av_opt_set_int(priv_data, "num_capture_buffers", 4, 0)) < 0) {
|
||||
LOG_WARN(std::string("v4l2m2m set num_capture_buffers failed, ret = ") + av_err2str(ret));
|
||||
LOG_DEBUG(std::string("v4l2m2m num_capture_buffers option is unavailable, ret = ") +
|
||||
av_err2str(ret));
|
||||
// Not fatal
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@ static thread_local std::string g_encoder_last_error;
|
||||
|
||||
static void set_encoder_last_error(const std::string &message) {
|
||||
g_encoder_last_error = message;
|
||||
LOG_ERROR(message);
|
||||
}
|
||||
|
||||
static int calculate_offset_length(int pix_fmt, int height, const int *linesize,
|
||||
@@ -646,7 +645,7 @@ ffmpeg_ram_new_encoder(const char *name, int width,
|
||||
// allowing CQP-only drivers to pass probing and normal encoder creation.
|
||||
if (name && std::string(name).find("vaapi") != std::string::npos &&
|
||||
rc != RC_CQ) {
|
||||
LOG_WARN(std::string("VAAPI bitrate-based rate control failed for ") +
|
||||
LOG_DEBUG(std::string("VAAPI bitrate-based rate control failed for ") +
|
||||
name + ", retrying with CQP");
|
||||
encoder = try_create(RC_CQ, 0);
|
||||
if (encoder) {
|
||||
|
||||
@@ -32,14 +32,14 @@ pub extern "C" fn hwcodec_av_log_callback(level: i32, message: *const std::os::r
|
||||
if let Ok(str_slice) = c_str.to_str() {
|
||||
let string = String::from(str_slice);
|
||||
if level == AV_LOG_ERROR as i32 {
|
||||
log::error!("{}", string);
|
||||
if string.contains(could_not_find_ref_with_poc) {
|
||||
hwcodec_set_flag_could_not_find_ref_with_poc();
|
||||
}
|
||||
log::debug!("{}", string);
|
||||
} else if level == AV_LOG_PANIC as i32 || level == AV_LOG_FATAL as i32 {
|
||||
log::error!("{}", string);
|
||||
} else if level == AV_LOG_WARNING as i32 {
|
||||
log::warn!("{}", string);
|
||||
log::debug!("{}", string);
|
||||
} else if level == AV_LOG_INFO as i32 {
|
||||
log::info!("{}", string);
|
||||
} else if level == AV_LOG_VERBOSE as i32 || level == AV_LOG_DEBUG as i32 {
|
||||
|
||||
@@ -343,7 +343,7 @@ fn log_failed_probe_attempt(
|
||||
}
|
||||
|
||||
fn validate_candidate(codec: &CodecInfo, ctx: &EncodeContext, yuv: &[u8]) -> bool {
|
||||
use log::{debug, warn};
|
||||
use log::debug;
|
||||
|
||||
debug!("Testing encoder: {}", codec.name);
|
||||
|
||||
@@ -395,7 +395,7 @@ fn validate_candidate(codec: &CodecInfo, ctx: &EncodeContext, yuv: &[u8]) -> boo
|
||||
}
|
||||
Err(err) => {
|
||||
last_err = Some(err);
|
||||
warn!(
|
||||
debug!(
|
||||
"Encoder {} test attempt {} returned error: {}",
|
||||
codec.name, attempt_no, err
|
||||
);
|
||||
@@ -412,10 +412,7 @@ fn validate_candidate(codec: &CodecInfo, ctx: &EncodeContext, yuv: &[u8]) -> boo
|
||||
);
|
||||
false
|
||||
}
|
||||
Err(_) => {
|
||||
warn!("Failed to create encoder {}", codec.name);
|
||||
false
|
||||
}
|
||||
Err(_) => false,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -543,7 +540,7 @@ impl Encoder {
|
||||
if codec.is_null() {
|
||||
let message = encoder_last_error_message();
|
||||
if !message.is_empty() {
|
||||
log::error!("ffmpeg_ram_new_encoder failed: {}", message);
|
||||
log::debug!("ffmpeg_ram_new_encoder failed: {}", message);
|
||||
}
|
||||
return Err(());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user