feat: adiciona suporte para excluir faixas de áudio e legenda do arquivo de saída
This commit is contained in:
@@ -61,8 +61,8 @@ impl FfmpegCommandBuilder {
|
||||
}
|
||||
|
||||
// ── Maps ────────────────────────────────────────────────────────────────
|
||||
// Faixas existentes do source
|
||||
for track in &project.existing_tracks {
|
||||
// Faixas existentes do source (excluídas pelo usuário são omitidas)
|
||||
for track in project.existing_tracks.iter().filter(|t| !t.excluded) {
|
||||
args.push("-map".to_string());
|
||||
if track.offset.is_zero() {
|
||||
args.push(format!("0:{}", track.stream_index));
|
||||
@@ -74,7 +74,9 @@ impl FfmpegCommandBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
// Se não há faixas existentes mapeadas, mapeia tudo do source
|
||||
// Se não há faixas existentes conhecidas (ffprobe não foi executado), mapeia tudo do source.
|
||||
// Quando existing_tracks está populado mas todas foram excluídas, o usuário optou
|
||||
// conscientemente por não incluir nenhuma faixa original — não emitimos -map 0.
|
||||
if project.existing_tracks.is_empty() {
|
||||
args.push("-map".to_string());
|
||||
args.push("0".to_string());
|
||||
@@ -364,4 +366,49 @@ mod tests {
|
||||
);
|
||||
assert!(args.contains(&"language=por".to_string()));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn faixa_existente_excluida_nao_aparece_em_map() {
|
||||
use crate::domain::entities::{MediaTrackInfo, TrackKind};
|
||||
use crate::domain::value_objects::TrackId;
|
||||
let mut project = base_project();
|
||||
let mut audio = MediaTrackInfo::new(
|
||||
TrackId::new(1),
|
||||
TrackKind::Audio,
|
||||
"aac",
|
||||
None,
|
||||
1,
|
||||
);
|
||||
audio.excluded = true;
|
||||
project.existing_tracks.push(audio);
|
||||
|
||||
let args = FfmpegCommandBuilder::build(&project);
|
||||
// -map 0:1 não deve aparecer pois a faixa está excluída
|
||||
assert!(
|
||||
!args.contains(&"0:1".to_string()),
|
||||
"faixa excluída não deve aparecer em -map — args: {:?}",
|
||||
args
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn faixa_existente_nao_excluida_aparece_em_map() {
|
||||
use crate::domain::entities::{MediaTrackInfo, TrackKind};
|
||||
use crate::domain::value_objects::TrackId;
|
||||
let mut project = base_project();
|
||||
project.existing_tracks.push(MediaTrackInfo::new(
|
||||
TrackId::new(1),
|
||||
TrackKind::Audio,
|
||||
"aac",
|
||||
None,
|
||||
1,
|
||||
));
|
||||
|
||||
let args = FfmpegCommandBuilder::build(&project);
|
||||
assert!(
|
||||
args.contains(&"0:1".to_string()),
|
||||
"faixa não excluída deve aparecer em -map — args: {:?}",
|
||||
args
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user