Add identify types

This commit is contained in:
Zoe Roux 2023-04-23 17:09:27 +09:00
parent f80289aef1
commit ea52ce1c65
No known key found for this signature in database

View File

@ -2,7 +2,39 @@ use serde::Serialize;
#[derive(Serialize)]
pub struct MediaInfo {
container: String,
video_codec: String,
audios: Vec<Track>,
subtitles: Vec<Track>,
fonts: Vec<String>,
chapters: Vec<Chapter>,
}
#[derive(Serialize)]
pub struct Track {
/// The index of this track on the media.
index: u32,
/// The title of the stream.
title: String,
/// The language of this stream (as a ISO-639-2 language code)
language: String,
/// The codec of this stream.
codec: String,
/// Is this stream the default one of it's type?
default: bool,
/// Is this stream tagged as forced? (useful only for subtitles)
forced: bool,
}
#[derive(Serialize)]
pub struct Chapter {
/// The start time of the chapter (in second from the start of the episode).
start: f32,
/// The end time of the chapter (in second from the start of the episode).
end: f32,
/// The name of this chapter. This should be a human-readable name that could be presented to the user.
name: String
// TODO: add a type field for Opening, Credits...
}
pub fn identify(path: String) -> Result<MediaInfo, std::io::Error> {