feat 拼接音频文件路径.
This commit is contained in:
parent
58fd589b5b
commit
74b205a32c
13
src/merge.rs
13
src/merge.rs
@ -1,6 +1,6 @@
|
|||||||
use std::fs;
|
|
||||||
use std::io::Result;
|
use std::io::Result;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
use std::{fs, io};
|
||||||
|
|
||||||
fn guess_video_path(path: &Path) -> Result<PathBuf> {
|
fn guess_video_path(path: &Path) -> Result<PathBuf> {
|
||||||
let mut largest_size = 0;
|
let mut largest_size = 0;
|
||||||
@ -23,7 +23,16 @@ fn guess_video_path(path: &Path) -> Result<PathBuf> {
|
|||||||
|
|
||||||
pub fn merge_video_from_path(path: &Path) -> Result<()> {
|
pub fn merge_video_from_path(path: &Path) -> Result<()> {
|
||||||
let video_path = guess_video_path(path)?;
|
let video_path = guess_video_path(path)?;
|
||||||
let video_name = video_path.file_name().unwrap();
|
let video_name = video_path.file_name().unwrap().to_str().unwrap();
|
||||||
|
let video_extension = video_path.extension().unwrap();
|
||||||
|
|
||||||
|
let audio_name = format!("{}.m4a", &video_name[..video_name.len() - video_extension.len() - 1]);
|
||||||
|
let audio_path = video_path.parent().unwrap().join(audio_name);
|
||||||
|
if !audio_path.exists() {
|
||||||
|
return Err(io::Error::new(io::ErrorKind::NotFound, "Audio file does not exist"));
|
||||||
|
}
|
||||||
|
|
||||||
|
println!("Merging video from {:?}", audio_path);
|
||||||
println!("Merging video {:?}", video_name);
|
println!("Merging video {:?}", video_name);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
Loading…
Reference in New Issue
Block a user