peggy/ffprobe
This module contains functions for interacting with FFprobe. FFprobe is used to get information about video files such as resolution, frame-rate, duration, etc. This module contains some helper utilities simplifying that process.
Types
Contains information about a video file This may be expanded to contain more data in updates
pub type StreamProperties {
StreamProperties(
width: String,
height: String,
sample_aspect_ratio: String,
aspect_ratio: String,
frame_rate: String,
)
}
Constructors
-
StreamProperties( width: String, height: String, sample_aspect_ratio: String, aspect_ratio: String, frame_rate: String, )
Functions
pub fn get_duration(file_path: String) -> Result(Float, String)
Get duration of video file as float
Usage
let assert Ok(duration) = ffprobe.get_duration("input.mp4")
pub fn get_video_info(
file_path: String,
) -> Result(StreamProperties, String)
Get information about a video file This information includes:
- width
- height
- sample aspect ratio (aspect ratio of pixels)
- aspect ratio (of video)
- frame rate (as fraction)
Usage
case ffprobe.get_video_info("input.mp4") {
Ok(StreamProperties(w, h, sar, ar, fr)) -> {...}
Error(msg) -> {...}
}
OR
let assert Ok(StreamProperties(w, h, sar, ar, fr)) =
ffprobe.get_video_info("input.mp4")