From c34cb1919f62d77263523d1253d3e852a8b3a565 Mon Sep 17 00:00:00 2001 From: Warren Lo Date: Wed, 11 Mar 2026 01:44:28 +0800 Subject: [PATCH] Add metadata.rs --- src/metadata.rs | 74 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 src/metadata.rs diff --git a/src/metadata.rs b/src/metadata.rs new file mode 100644 index 0000000..d1bd337 --- /dev/null +++ b/src/metadata.rs @@ -0,0 +1,74 @@ +use serde::{Deserialize, Serialize}; +use chrono::{DateTime, Utc}; + +#[derive(Debug, Serialize, Deserialize)] +pub struct VideoMetadata { + pub video_path: String, + pub probed_at: DateTime, + pub format: FormatInfo, + pub video_stream: Option, + pub audio_streams: Vec, + pub subtitle_streams: Vec, + pub other_streams: Vec, +} + +#[derive(Debug, Serialize, Deserialize, Default)] +pub struct FormatInfo { + pub filename: Option, + pub format_name: Option, + pub format_long_name: Option, + pub duration: f64, + pub size: u64, + pub bit_rate: u64, + pub probe_score: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub tags: Option, +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct VideoStream { + pub index: i32, + pub codec_name: Option, + pub codec_long_name: Option, + pub profile: Option, + pub width: i32, + pub height: i32, + pub pix_fmt: Option, + pub r_frame_rate: Option, + pub avg_frame_rate: Option, + pub bit_rate: Option, + pub duration: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub tags: Option, +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct AudioStream { + pub index: i32, + pub codec_name: Option, + pub channels: i32, + pub sample_rate: Option, + pub bit_rate: Option, + pub duration: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub tags: Option, +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct SubtitleStream { + pub index: i32, + pub codec_name: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub language: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub tags: Option, +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct OtherStream { + pub index: i32, + pub codec_type: String, + pub codec_name: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub tags: Option, +} \ No newline at end of file