feat: implementa funcionalidade de exportação de faixas de áudio e legenda
This commit is contained in:
+41
-1
@@ -1,10 +1,12 @@
|
||||
use eframe::egui;
|
||||
use std::sync::mpsc;
|
||||
use crate::adapters::ffmpeg::{FfmpegCommandBuilder, FfmpegGateway, FfprobeGateway};
|
||||
use crate::adapters::filesystem::file_picker::FilePickerAdapter;
|
||||
use crate::application::ports::MediaProcessorPort;
|
||||
use crate::application::use_cases::{
|
||||
add_audio_track::AddAudioTrack, add_subtitle::AddSubtitle,
|
||||
edit_existing_track_sync::EditExistingTrackSync, load_media_info::LoadMediaInfo,
|
||||
edit_existing_track_sync::EditExistingTrackSync, export_track::ExportTrack,
|
||||
load_media_info::LoadMediaInfo,
|
||||
};
|
||||
use crate::domain::entities::{MkvOutput, Project, VideoFile};
|
||||
use crate::domain::value_objects::FilePath;
|
||||
@@ -200,10 +202,48 @@ impl eframe::App for App {
|
||||
self.existing_track_list.ui(ui, &project.existing_tracks);
|
||||
for event in events {
|
||||
use crate::ui::components::existing_track_list::ExistingTrackEvent;
|
||||
use crate::domain::entities::TrackKind;
|
||||
match event {
|
||||
ExistingTrackEvent::OffsetChanged(id, offset) => {
|
||||
let _ = EditExistingTrackSync::execute(project, id, offset);
|
||||
}
|
||||
ExistingTrackEvent::ExportRequested(id) => {
|
||||
// Localiza a faixa pelo id
|
||||
if let Some(track) = project
|
||||
.existing_tracks
|
||||
.iter()
|
||||
.find(|t| t.id == id)
|
||||
.cloned()
|
||||
{
|
||||
let maybe_output = match track.kind {
|
||||
TrackKind::Audio => FilePickerAdapter::save_audio(&track.codec),
|
||||
TrackKind::Subtitle => FilePickerAdapter::save_subtitle(&track.codec),
|
||||
_ => None,
|
||||
};
|
||||
if let Some(output_path) = maybe_output {
|
||||
let gateway = FfmpegGateway;
|
||||
match ExportTrack::execute(
|
||||
&project.source.path,
|
||||
&track,
|
||||
&output_path,
|
||||
&gateway,
|
||||
) {
|
||||
Ok(_) => {
|
||||
self.execution_panel.state =
|
||||
ExecutionState::Success;
|
||||
self.execution_panel.add_log(format!(
|
||||
"Faixa exportada para: {}",
|
||||
output_path.to_string_lossy()
|
||||
));
|
||||
}
|
||||
Err(e) => {
|
||||
self.execution_panel.state =
|
||||
ExecutionState::Error(e.to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user