mirror of
https://github.com/crunchy-labs/crunchy-cli.git
synced 2026-01-21 04:02:00 -06:00
Show error message instead of panicking when capturing video length of invalid file (#258)
This commit is contained in:
parent
d5df3df95f
commit
8f77028fcb
1 changed files with 7 additions and 1 deletions
|
|
@ -768,7 +768,13 @@ pub fn get_video_length(path: &Path) -> Result<NaiveTime> {
|
|||
.args(["-i", path.to_str().unwrap()])
|
||||
.output()?;
|
||||
let ffmpeg_output = String::from_utf8(ffmpeg.stderr)?;
|
||||
let caps = video_length.captures(ffmpeg_output.as_str()).unwrap();
|
||||
let caps = video_length.captures(ffmpeg_output.as_str()).map_or(
|
||||
Err(anyhow::anyhow!(
|
||||
"failed to get video length: {}",
|
||||
ffmpeg_output
|
||||
)),
|
||||
Ok,
|
||||
)?;
|
||||
|
||||
Ok(NaiveTime::parse_from_str(caps.name("time").unwrap().as_str(), "%H:%M:%S%.f").unwrap())
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue