diff --git a/.gitignore b/.gitignore index ea8c4bf..d569ccf 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -/target +target +*.lock diff --git a/src/font.rs b/src/font.rs index 9f47acb..0e50725 100644 --- a/src/font.rs +++ b/src/font.rs @@ -3,7 +3,10 @@ use font_kit::source::SystemSource; pub fn load_fonts(ctx: &egui::Context) { let sys = SystemSource::new(); let font_name = format!("SimHei"); - let font = sys.select_family_by_name(&font_name).unwrap().fonts()[0] + let font = sys + .select_family_by_name(&font_name) + .unwrap() + .fonts()[0] .load() .unwrap() .copy_font_data() diff --git a/src/ui.rs b/src/ui.rs index 003c7b7..a744c14 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -28,8 +28,8 @@ struct Config { #[derive(Debug, Clone, Default)] pub struct Files { pub audio: Option, - image: Option, - subtitle: Option, + pub image: Option, + pub subtitle: Option, } impl Conv { diff --git a/src/utils.rs b/src/utils.rs index 3844811..f36b27c 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -16,14 +16,19 @@ fn as_lrc(t: &Transcript) -> String { .iter() .fold(String::new(), |lrc, fragment| { lrc + + format!( + "[{:02}:{:02}.{:02}]\n", + fragment.start / 100 / 60, + fragment.start / 100, + fragment.start % 100, + ).as_str() + format!( "[{:02}:{:02}.{:02}]{}\n", fragment.start / 100 / 60, fragment.start / 100, fragment.start % 100, fragment.text - ) - .as_str() + ).as_str() }) } @@ -53,6 +58,7 @@ pub fn ffmpeg_merge(audio: Option, image: Option, subtitle: Op cmd.args([ "-loop", "1", + "-y", "-i", image.to_str().unwrap(), ]); @@ -60,19 +66,15 @@ pub fn ffmpeg_merge(audio: Option, image: Option, subtitle: Op if let (Some(ref audio), Some(ref subtitle)) = (audio, subtitle) { let output = audio.with_extension("mp4"); if output.exists() { - fs::remove_file(output).unwrap_or(()); + fs::remove_file(&output).unwrap_or(()); } cmd.args([ "-i", audio.to_str().unwrap(), "-vf", - &format!("subtitles={}", subtitle.file_name().unwrap().to_str().unwrap()), - // "-c:v", - // "copy", - // "-c:a", - // "copy", + &format!("subtitles={}", subtitle.to_str().unwrap()), "-shortest", - audio.with_extension("mp4").to_str().unwrap(), + output.to_str().unwrap(), ]); } else { MERGE.store(false, Ordering::Relaxed);