auto codec, h265 > h264 > vp9/vp8 (#8032)

Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
21pages 2024-05-13 16:27:48 +08:00 committed by GitHub
parent a7499c2de8
commit 7e09809ad8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -267,13 +267,21 @@ impl Encoder {
.unwrap_or((PreferCodec::Auto.into(), 0));
let preference = most_frequent.enum_value_or(PreferCodec::Auto);
#[allow(unused_mut)]
// auto: h265 > h264 > vp9/vp8
let mut auto_codec = CodecFormat::VP9;
let mut system = System::new();
system.refresh_memory();
if vp8_useable && system.total_memory() <= 4 * 1024 * 1024 * 1024 {
// 4 Gb
auto_codec = CodecFormat::VP8
if h264_useable {
auto_codec = CodecFormat::H264;
}
if h265_useable {
auto_codec = CodecFormat::H265;
}
if auto_codec == CodecFormat::VP9 {
let mut system = System::new();
system.refresh_memory();
if vp8_useable && system.total_memory() <= 4 * 1024 * 1024 * 1024 {
// 4 Gb
auto_codec = CodecFormat::VP8
}
}
*format = match preference {