feat(video): add codec and resolution controls
Some checks failed
Build Release Binaries / build-amd64 (push) Failing after 3m38s
Mirror to GitHub / mirror (push) Failing after 38s

This commit is contained in:
Siavash Sameni
2026-05-26 10:05:20 +04:00
parent f85efb9576
commit 9a7745978b
7 changed files with 250 additions and 92 deletions

View File

@@ -519,11 +519,12 @@ impl VideoEncoder for MediaCodecHevcEncoder {
}
fn is_keyframe(&self, packet: &[u8]) -> bool {
if packet.len() < 2 {
return false;
let nals = split_annex_b(packet);
if nals.is_empty() {
return packet.len() >= 2 && matches!((packet[0] >> 1) & 0x3F, 19 | 20);
}
let nal_type = (packet[0] >> 1) & 0x3F;
nal_type == 19 || nal_type == 20
nals.iter()
.any(|nal| nal.len() >= 2 && matches!((nal[0] >> 1) & 0x3F, 19 | 20))
}
}

View File

@@ -164,7 +164,8 @@ impl VideoEncoder for VideoToolboxEncoder {
if nals.is_empty() {
return (packet[0] & 0x1F) == 5;
}
nals.iter().any(|nal| !nal.is_empty() && (nal[0] & 0x1F) == 5)
nals.iter()
.any(|nal| !nal.is_empty() && (nal[0] & 0x1F) == 5)
}
}
@@ -522,12 +523,13 @@ impl VideoEncoder for VideoToolboxHevcEncoder {
}
fn is_keyframe(&self, packet: &[u8]) -> bool {
if packet.len() < 2 {
return false;
let nals = split_annex_b(packet);
if nals.is_empty() {
return packet.len() >= 2 && matches!((packet[0] >> 1) & 0x3F, 19 | 20);
}
let nal_type = (packet[0] >> 1) & 0x3F;
// NAL type 19 = IDR_W_RADL, 20 = IDR_N_LP.
nal_type == 19 || nal_type == 20
nals.iter()
.any(|nal| nal.len() >= 2 && matches!((nal[0] >> 1) & 0x3F, 19 | 20))
}
}