feat: allow emmiting frames on stdout to pipe them in ffmpeg

This commit is contained in:
2026-09-28 08:40:00 +02:00
parent d78594af7e
commit 27c5a1a603
5 changed files with 135 additions and 18 deletions
+19 -5
View File
@@ -1608,17 +1608,15 @@ pub fn render_readback_blocking(
bytes
}
/// Like [`encode_png_with_progress`], but encodes the whole image at once
/// (no progress) at the given compression level. Non-streaming, so the fast
/// `fdeflate` levels don't pay the streaming-mode size penalty.
/// Strip a readback's row padding and convert it to tightly-packed RGBA8
/// (`width * height * 4` bytes, rows top to bottom).
#[cfg(not(target_arch = "wasm32"))]
pub fn encode_png(
pub fn unpad_rgba(
padded: &[u8],
width: u32,
height: u32,
padded_bpr: u32,
swap_rb: bool,
compression: png::Compression,
) -> Vec<u8> {
let row = (width * 4) as usize;
let mut pixels = Vec::with_capacity(row * height as usize);
@@ -1636,6 +1634,22 @@ pub fn encode_png(
pixels.extend_from_slice(src);
}
}
pixels
}
/// Like [`encode_png_with_progress`], but encodes the whole image at once
/// (no progress) at the given compression level. Non-streaming, so the fast
/// `fdeflate` levels don't pay the streaming-mode size penalty.
#[cfg(not(target_arch = "wasm32"))]
pub fn encode_png(
padded: &[u8],
width: u32,
height: u32,
padded_bpr: u32,
swap_rb: bool,
compression: png::Compression,
) -> Vec<u8> {
let pixels = unpad_rgba(padded, width, height, padded_bpr, swap_rb);
let mut out = Vec::new();
{