vidsage-core 0.1.0

Core functionality for VidSage video processing and AI commentary generation
Documentation
//! Video processor implementation

use std::path::PathBuf;

use super::metadata::{VideoFormat, VideoQuality};
use super::VideoMetadata;
use serde::{Deserialize, Serialize};

/// Compression level settings
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq)]
pub enum CompressionLevel {
    #[serde(rename = "low")]
    Low,
    #[serde(rename = "medium")]
    Medium,
    #[serde(rename = "high")]
    High,
    #[serde(rename = "ultra")]
    Ultra,
    #[serde(rename = "custom")]
    Custom(f32), // Compression ratio (0.1-1.0)
}

/// Processing status enumeration
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub enum ProcessingStatus {
    #[serde(rename = "pending")]
    Pending,
    #[serde(rename = "processing")]
    Processing {
        progress: u8, // 0-100%
        current_step: String,
    },
    #[serde(rename = "completed")]
    Completed,
    #[serde(rename = "failed")]
    Failed { error: String },
    #[serde(rename = "cancelled")]
    Cancelled,
}

/// Video processing options
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ProcessOptions {
    /// Output video quality
    pub quality: VideoQuality,

    /// Output video format
    pub format: VideoFormat,

    /// Compression level
    pub compression: CompressionLevel,

    /// Whether to extract audio
    pub extract_audio: bool,

    /// Whether to extract metadata
    pub extract_metadata: bool,

    /// Output resolution (optional, defaults to original)
    pub resolution: Option<(u32, u32)>,

    /// Output frame rate (optional, defaults to original)
    pub frame_rate: Option<f64>,

    /// Whether to enable hardware acceleration
    pub hardware_acceleration: bool,

    /// Number of threads to use for processing
    pub threads: Option<u32>,
}

impl Default for ProcessOptions {
    fn default() -> Self {
        Self {
            quality: VideoQuality::Medium,
            format: VideoFormat::MP4,
            compression: CompressionLevel::Medium,
            extract_audio: false,
            extract_metadata: true,
            resolution: None,
            frame_rate: None,
            hardware_acceleration: true,
            threads: None,
        }
    }
}

/// Video data structure for processing
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct VideoData {
    /// Video metadata
    pub metadata: VideoMetadata,

    /// Path to the video file
    pub path: PathBuf,

    /// Whether the video is processed
    pub is_processed: bool,

    /// Processing job ID (if any)
    pub job_id: Option<String>,
}

/// Video processing output
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct VideoOutput {
    /// Processed video metadata
    pub metadata: VideoMetadata,

    /// Path to the processed video file
    pub processed_path: PathBuf,

    /// Processing status
    pub status: ProcessingStatus,

    /// Processing time in seconds
    pub processing_time: f64,

    /// Original file path
    pub original_path: PathBuf,

    /// Extracted audio path (if requested)
    pub audio_path: Option<PathBuf>,

    /// Extracted metadata (if requested)
    pub extracted_metadata: Option<VideoMetadata>,
}