voelinctl: list the video encoders, bench and stream with any of them

`voelinctl stream encoders` prints the FFmpeg libraries found, every
encoder backend with its self-test result or why it cannot be used, and
the order the streamer tries them in (--encoder / --no-hardware rank as
the settings would). `stream bench` and `stream start` take --encoder,
--no-hardware and a --codec that defaults to the named encoder's codec
or the choice's first; they print the backend in use. `stream start`
feeds a FrameSource, which does not tell codecs apart, so it offers its
stream codec alone; with the test pattern the H.264 level follows its
size, rate and bitrate.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
This commit is contained in:
Claude committed 2026-09-29 00:56:41 +00:00
1 parent dd8b628909
commit 3ae804569a
6 files changed
+171 -30

No files matched your search

+10 -4
View File
@@ -1002,7 +1002,8 @@ impl Streamer {
for (spec, &threads) in specs.iter().zip(&split) {
let existing = current.iter().any(|l| l.id == spec.id);
if !existing || codec_changed {
let encoder = new_encoder(codecs, next.codec, &next.encoder, spec, next.fps, threads)?;
let encoder =
new_encoder(codecs, next.codec, &next.encoder, spec, next.fps, threads)?;
created.push((spec.id, encoder));
}
}
@@ -1696,7 +1697,9 @@ fn encode_loop(shared: &Shared, layer: &Layer, encoder: Box<dyn VideoEncoder>) {
let fps = layer.fps.load(Ordering::Relaxed);
extra.push(match extra_encoder(shared, layer, codec) {
Some(encoder) => LayerEncoder::new(encoder, fps),
None => LayerEncoder { codec, encoder: None, keyframe_due: false, bitrate: 0, fps },
None => {
LayerEncoder { codec, encoder: None, keyframe_due: false, bitrate: 0, fps }
}
});
}
}
@@ -2553,8 +2556,11 @@ mod tests {
*lock(&sink.codecs) = vec![Codec::Vp8, Codec::Vp9];
wait_for(Codec::Vp9, 5).await;
assert_eq!(streamer.stats().layers[0].codecs, [Codec::Vp8, Codec::Vp9]);
let vp9: Vec<EncodedFrame> =
lock(&sink.frames).iter().filter(|(c, _)| *c == Codec::Vp9).map(|(_, f)| f.clone()).collect();
let vp9: Vec<EncodedFrame> = lock(&sink.frames)
.iter()
.filter(|(c, _)| *c == Codec::Vp9)
.map(|(_, f)| f.clone())
.collect();
assert!(is_keyframe(Codec::Vp9, &vp9[0].data), "the first VP9 frame is a keyframe");
let mut decoder = codecs.new_decoder(Codec::Vp9).unwrap();
for frame in &vp9 {
+1 -1
View File
@@ -14,8 +14,8 @@
//! (hardware, or Google's software VP8 / VP9 / H.264)
use std::fmt;
use std::sync::Arc;
use std::str::FromStr;
use std::sync::Arc;
use crate::frame::VideoFrame;
use crate::{Error, Result};
@@ -1089,6 +1089,7 @@ fn test_backend(spec: &'static BackendSpec) -> std::result::Result<(), String> {
Ok((_, false)) => Err("the test frame did not come out as a keyframe".into()),
Ok(_) => Ok(()),
Err(Error::CodecUnavailable { reason, .. }) => Err(reason),
Err(Error::Encoder { message, .. }) => Err(message),
Err(e) => Err(e.to_string()),
}
}
+2 -3
View File
@@ -1205,9 +1205,8 @@ impl StreamerSession {
fn emit_viewers(&mut self, out: &mut Outbox) {
// Every change of the viewers comes through here: the encoders learn
// which codecs are needed now.
self.feedback.set_codecs(
self.viewers.values().filter(|v| v.peer.is_some()).filter_map(|v| v.codec),
);
self.feedback
.set_codecs(self.viewers.values().filter(|v| v.peer.is_some()).filter_map(|v| v.codec));
self.last_viewers_event = Some(Instant::now());
out.event(StreamEvent::Streamer(StreamerEvent::Viewers(self.viewers())));
}