Skip to content

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

chore: remove debug logging from audio mix

Domicad1257b74669a
diff --git a/src/crates/concat-media/src/audio.rs b/src/crates/concat-media/src/audio.rs
index bb6d2f49..c7a36835 100644
--- a/src/crates/concat-media/src/audio.rs
+++ b/src/crates/concat-media/src/audio.rs
@@ -12,7 +12,6 @@
//! definition of what speed, fades and gain mean for sound - the same reason
//! `Clip::source_time_at` is the one definition for picture.
-use std::io::Write;
use std::path::Path;
use concat_core::animate::Track;
@@ -573,21 +572,7 @@ pub fn mix_to_file(clips: &[AudioClip], duration: f64, destination: &Path) -> Re
// Break, do not return: the finalisation below this loop
// flushes the encoder and writes the trailer, and an m4a
// without its trailer cannot be opened by the muxer.
- Err(ffmpeg::Error::Eof) => {
- if let Ok(mut f) = std::fs::OpenOptions::new()
- .create(true)
- .append(true)
- .open(std::env::temp_dir().join("concat-mix.log"))
- {
- let expected = (duration * 48000.0) as i64;
- let _ = writeln!(
- f,
- "[mix] sink EOF at sample {} of ~{}",
- written_samples, expected
- );
- }
- break 'mix;
- }
+ Err(ffmpeg::Error::Eof) => break 'mix,
Err(error) if ffi::is_again(&error) => break,
Err(error) => return Err(ffi::fail("filter output", destination, error)),
}
@@ -627,18 +612,6 @@ pub fn mix_to_file(clips: &[AudioClip], duration: f64, destination: &Path) -> Re
// Take what it got and end the input gracefully
// instead of failing the whole mix on a trimmed clip.
Err(ffmpeg::Error::Eof) => {
- if let Ok(mut f) = std::fs::OpenOptions::new()
- .create(true)
- .append(true)
- .open(std::env::temp_dir().join("concat-mix.log"))
- {
- let _ = writeln!(
- f,
- "[mix] graph closed {} at sample {}",
- input.path.display(),
- written_samples
- );
- }
let _ = context.source().flush();
input.done = true;
}
@@ -646,18 +619,6 @@ pub fn mix_to_file(clips: &[AudioClip], duration: f64, destination: &Path) -> Re
}
}
None => {
- if let Ok(mut f) = std::fs::OpenOptions::new()
- .create(true)
- .append(true)
- .open(std::env::temp_dir().join("concat-mix.log"))
- {
- let _ = writeln!(
- f,
- "[mix] decoder EOF for {} at sample {}",
- input.path.display(),
- written_samples
- );
- }
let mut context = graph.get(&input.label).expect("source exists");
let _ = context.source().flush();
input.done = true;
@@ -735,31 +696,30 @@ pub fn mux(video: &Path, audio: &Path, output: &Path) -> Result<()> {
// soundtrack died at exactly 30/46.9 of the picture. `write_interleaved`
// still does the final ordering; feeding it in order keeps its buffer
// small. The file ends with the shorter input, as `-shortest`.
- let mut next_packet =
- |input: &mut ffmpeg::format::context::Input,
- wanted: usize,
- from: ffmpeg::Rational,
- to: ffmpeg::Rational,
- stream: usize,
- path: &Path|
+ let next_packet = |input: &mut ffmpeg::format::context::Input,
+ wanted: usize,
+ from: ffmpeg::Rational,
+ to: ffmpeg::Rational,
+ stream: usize,
+ path: &Path|
-> Result<Option<ffmpeg::Packet>> {
- loop {
- let mut packet = ffmpeg::Packet::empty();
- match packet.read(input) {
- Ok(()) => {
- if packet.stream() != wanted {
- continue;
- }
- packet.set_stream(stream);
- packet.rescale_ts(from, to);
- packet.set_position(-1);
- return Ok(Some(packet));
+ loop {
+ let mut packet = ffmpeg::Packet::empty();
+ match packet.read(input) {
+ Ok(()) => {
+ if packet.stream() != wanted {
+ continue;
}
- Err(ffmpeg::Error::Eof) => return Ok(None),
- Err(error) => return Err(ffi::fail("read", path, error)),
+ packet.set_stream(stream);
+ packet.rescale_ts(from, to);
+ packet.set_position(-1);
+ return Ok(Some(packet));
}
+ Err(ffmpeg::Error::Eof) => return Ok(None),
+ Err(error) => return Err(ffi::fail("read", path, error)),
}
- };
+ }
+ };
// Timestamps from each input arrive in that input's own time base -
// 1/15360 for this project's video, 1/48000 for its audio - so a bare
@@ -791,14 +751,14 @@ pub fn mux(video: &Path, audio: &Path, output: &Path) -> Result<()> {
(None, None) => break,
};
if take_video {
- let mut packet = video_packet.take().expect("checked above");
+ let packet = video_packet.take().expect("checked above");
packet
.write_interleaved(&mut out)
.map_err(|error| ffi::fail("write packet", output, error))?;
video_packet =
next_packet(&mut video_in, video_index, video_tb, out_video_tb, 0, video)?;
} else {
- let mut packet = audio_packet.take().expect("checked above");
+ let packet = audio_packet.take().expect("checked above");
packet
.write_interleaved(&mut out)
.map_err(|error| ffi::fail("write packet", output, error))?;