Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
name committed Jun 26, 2023
1 parent 71949df commit 9ed9f77
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 13 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/target
target
*.lock
5 changes: 4 additions & 1 deletion src/font.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ struct Config {
#[derive(Debug, Clone, Default)]
pub struct Files {
pub audio: Option<PathBuf>,
image: Option<PathBuf>,
subtitle: Option<PathBuf>,
pub image: Option<PathBuf>,
pub subtitle: Option<PathBuf>,
}

impl Conv {
Expand Down
20 changes: 11 additions & 9 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
})
}

Expand Down Expand Up @@ -53,26 +58,23 @@ pub fn ffmpeg_merge(audio: Option<PathBuf>, image: Option<PathBuf>, subtitle: Op
cmd.args([
"-loop",
"1",
"-y",
"-i",
image.to_str().unwrap(),
]);
}
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);
Expand Down

0 comments on commit 9ed9f77

Please sign in to comment.