feat 获取视频文件.

This commit is contained in:
licsber 2024-09-29 14:56:57 +08:00
parent 32fa27ef87
commit 58fd589b5b
2 changed files with 25 additions and 2 deletions

View File

@ -1,7 +1,6 @@
mod merge;
use std::env;
use std::error::Error;
use std::io::Result;
use std::path::PathBuf;

View File

@ -1,6 +1,30 @@
use std::path::Path;
use std::fs;
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<()> {
let video_path = guess_video_path(path)?;
let video_name = video_path.file_name().unwrap();
println!("Merging video {:?}", video_name);
Ok(())
}