-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
104 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
use std::path::Path; | ||
|
||
use serde::Deserialize; | ||
use tokio::process::Command; | ||
|
||
#[derive(Deserialize)] | ||
pub struct Ffprobe { | ||
pub streams: Option<Vec<Streams>>, | ||
pub format: Option<Format>, | ||
} | ||
|
||
#[derive(Deserialize)] | ||
pub struct Streams { | ||
pub codec_type: Option<String>, | ||
pub width: Option<i32>, | ||
pub height: Option<i32>, | ||
pub tags: Option<Tags>, | ||
} | ||
|
||
#[derive(Deserialize)] | ||
pub struct Tags { | ||
pub title: Option<String>, | ||
pub artist: Option<String>, | ||
} | ||
|
||
#[derive(Deserialize)] | ||
pub struct Format { | ||
pub duration: String, | ||
} | ||
|
||
pub async fn ffprobe(path: &Path) -> serde_json::Result<Ffprobe> { | ||
let output = Command::new("ffprobe") | ||
.arg("-v") | ||
.arg("quiet") | ||
.arg("-output_format") | ||
.arg("json") | ||
.arg("-show_format") | ||
.arg("-show_streams") | ||
.arg(path) | ||
.output() | ||
.await | ||
.unwrap(); | ||
|
||
serde_json::from_slice(&output.stdout) | ||
} |