mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-03-15 07:26:44 +08:00
Merge branch 'main' into main
This commit is contained in:
@@ -508,4 +508,4 @@ bool has_flag_could_not_find_ref_with_poc() {
|
||||
|
||||
extern "C" void hwcodec_set_flag_could_not_find_ref_with_poc() {
|
||||
util_decode::g_flag_could_not_find_ref_with_poc = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
include!(concat!(env!("OUT_DIR"), "/ffmpeg_ffi.rs"));
|
||||
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
use std::env;
|
||||
|
||||
#[derive(Debug, Eq, PartialEq, Clone, Copy, Serialize, Deserialize)]
|
||||
pub enum AVHWDeviceType {
|
||||
@@ -53,7 +54,36 @@ pub extern "C" fn hwcodec_av_log_callback(level: i32, message: *const std::os::r
|
||||
pub(crate) fn init_av_log() {
|
||||
static INIT: std::sync::Once = std::sync::Once::new();
|
||||
INIT.call_once(|| unsafe {
|
||||
av_log_set_level(AV_LOG_ERROR as i32);
|
||||
av_log_set_level(parse_ffmpeg_log_level());
|
||||
hwcodec_set_av_log_callback();
|
||||
});
|
||||
}
|
||||
|
||||
fn parse_ffmpeg_log_level() -> i32 {
|
||||
let raw = match env::var("ONE_KVM_FFMPEG_LOG") {
|
||||
Ok(value) => value,
|
||||
Err(_) => return AV_LOG_ERROR as i32,
|
||||
};
|
||||
|
||||
let value = raw.trim().to_ascii_lowercase();
|
||||
if value.is_empty() {
|
||||
return AV_LOG_ERROR as i32;
|
||||
}
|
||||
|
||||
if let Ok(level) = value.parse::<i32>() {
|
||||
return level;
|
||||
}
|
||||
|
||||
match value.as_str() {
|
||||
"quiet" => AV_LOG_QUIET as i32,
|
||||
"panic" => AV_LOG_PANIC as i32,
|
||||
"fatal" => AV_LOG_FATAL as i32,
|
||||
"error" => AV_LOG_ERROR as i32,
|
||||
"warn" | "warning" => AV_LOG_WARNING as i32,
|
||||
"info" => AV_LOG_INFO as i32,
|
||||
"verbose" => AV_LOG_VERBOSE as i32,
|
||||
"debug" => AV_LOG_DEBUG as i32,
|
||||
"trace" => AV_LOG_TRACE as i32,
|
||||
_ => AV_LOG_ERROR as i32,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,8 +31,10 @@ unsafe impl Send for HwMjpegH26xPipeline {}
|
||||
impl HwMjpegH26xPipeline {
|
||||
pub fn new(config: HwMjpegH26xConfig) -> Result<Self, String> {
|
||||
unsafe {
|
||||
let dec = CString::new(config.decoder.as_str()).map_err(|_| "decoder name invalid".to_string())?;
|
||||
let enc = CString::new(config.encoder.as_str()).map_err(|_| "encoder name invalid".to_string())?;
|
||||
let dec = CString::new(config.decoder.as_str())
|
||||
.map_err(|_| "decoder name invalid".to_string())?;
|
||||
let enc = CString::new(config.encoder.as_str())
|
||||
.map_err(|_| "encoder name invalid".to_string())?;
|
||||
let ctx = ffmpeg_hw_mjpeg_h26x_new(
|
||||
dec.as_ptr(),
|
||||
enc.as_ptr(),
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
use crate::{
|
||||
ffmpeg::{init_av_log, AVPixelFormat},
|
||||
ffmpeg_ram::{
|
||||
ffmpeg_ram_decode, ffmpeg_ram_free_decoder, ffmpeg_ram_last_error,
|
||||
ffmpeg_ram_new_decoder,
|
||||
ffmpeg_ram_decode, ffmpeg_ram_free_decoder, ffmpeg_ram_last_error, ffmpeg_ram_new_decoder,
|
||||
},
|
||||
};
|
||||
use std::{
|
||||
|
||||
@@ -352,6 +352,7 @@ impl Encoder {
|
||||
debug!("Encoder {} created successfully", codec.name);
|
||||
let mut passed = false;
|
||||
let mut last_err: Option<i32> = None;
|
||||
let is_v4l2m2m = codec.name.contains("v4l2m2m");
|
||||
|
||||
let max_attempts = if codec.name.contains("v4l2m2m") {
|
||||
5
|
||||
|
||||
Reference in New Issue
Block a user