feat 获取视频文件.
This commit is contained in:
parent
32fa27ef87
commit
58fd589b5b
@ -1,7 +1,6 @@
|
|||||||
mod merge;
|
mod merge;
|
||||||
|
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::error::Error;
|
|
||||||
use std::io::Result;
|
use std::io::Result;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
|
26
src/merge.rs
26
src/merge.rs
@ -1,6 +1,30 @@
|
|||||||
use std::path::Path;
|
use std::fs;
|
||||||
use std::io::Result;
|
use std::io::Result;
|
||||||
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
|
fn guess_video_path(path: &Path) -> Result<PathBuf> {
|
||||||
|
let mut largest_size = 0;
|
||||||
|
let mut largest_file = PathBuf::from(path);
|
||||||
|
for entry in fs::read_dir(path)? {
|
||||||
|
let entry_path = entry?.path().canonicalize()?;
|
||||||
|
if entry_path.is_dir() {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
let size = entry_path.metadata()?.len();
|
||||||
|
if size > largest_size {
|
||||||
|
largest_size = size;
|
||||||
|
largest_file = entry_path.into();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(largest_file)
|
||||||
|
}
|
||||||
|
|
||||||
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_name = video_path.file_name().unwrap();
|
||||||
|
println!("Merging video {:?}", video_name);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user