1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
crate::ix!();
impl BatchModeTtsJob {
// -----------------------------------------------------------------------
// Helper: merge with ffmpeg concat demuxer
// -----------------------------------------------------------------------
pub async fn merge_parts_ffmpeg(&self, parts: &[PathBuf]) -> Result<(), BatchModeTtsError> {
// Build concat‑list file
let list_path = self
.output_path()
.with_file_name("ffmpeg_concat_list.txt");
let mut list_file = File::create(&list_path)?;
for p in parts {
writeln!(list_file, "file '{}'", p.display())?;
}
drop(list_file);
// Run ffmpeg
let status = Command::new("ffmpeg")
.args([
"-y",
"-f",
"concat",
"-safe",
"0",
"-i",
list_path.to_str().unwrap(),
"-c",
"copy",
self.output_path().to_str().unwrap(),
])
.status()?;
if status.success() {
debug!("ffmpeg merged parts successfully");
Ok(())
} else {
error!("ffmpeg returned non‑zero status {status}");
Err(
BatchModeTtsError::FfmpegMergeError { status }
)
}
}
}