Skip to content

The truly free, open-source, local-first, cross-platform CapCut replacement. Scriptable through a JSON-RPC API & MCP.

fix(media): drop FFmpeg's log lines below the level before formatting them

Jareer289de2a2fd67
diff --git a/src/crates/concat-media/src/ffi.rs b/src/crates/concat-media/src/ffi.rs
index 4a5a4709..80233193 100644
--- a/src/crates/concat-media/src/ffi.rs
+++ b/src/crates/concat-media/src/ffi.rs
@@ -48,6 +48,17 @@ unsafe extern "C" fn relay(
format: *const c_char,
args: ffmpeg::sys::va_list,
) {
+ // The level set in `init` is applied by FFmpeg's *default* callback,
+ // not before the callback is called: a callback of our own is handed
+ // every message there is, the per-packet debug and trace lines of a
+ // decoder included, thousands a second under a scrub. They are
+ // dropped here before anything is formatted, as the default drops
+ // them - the first version of this relay formatted them all, and
+ // scrubbing crawled.
+ // SAFETY: reads a global integer.
+ if level > unsafe { ffmpeg::sys::av_log_get_level() } {
+ return;
+ }
let mut line = [0 as c_char; 1024];
let mut print_prefix: c_int = 1;
// SAFETY: the buffer is ours and its length is passed with it; the