asonix
b48a9233b2
Video transcoding still happens, but in many cases the video stream is able to be copied verbatim rather than being decoded & encoded
40 lines
957 B
Rust
40 lines
957 B
Rust
mod exiftool;
|
|
mod ffmpeg;
|
|
mod magick;
|
|
|
|
use actix_web::web::Bytes;
|
|
|
|
use crate::formats::InputFile;
|
|
|
|
#[derive(Debug, PartialEq, Eq)]
|
|
pub(crate) struct Discovery {
|
|
pub(crate) input: InputFile,
|
|
pub(crate) width: u16,
|
|
pub(crate) height: u16,
|
|
pub(crate) frames: Option<u32>,
|
|
}
|
|
|
|
#[derive(Debug, thiserror::Error)]
|
|
pub(crate) enum DiscoverError {
|
|
#[error("No frames in uploaded media")]
|
|
NoFrames,
|
|
|
|
#[error("Not all frames have same image format")]
|
|
FormatMismatch,
|
|
|
|
#[error("Input file type {0} is unsupported")]
|
|
UnsupportedFileType(String),
|
|
}
|
|
|
|
pub(crate) async fn discover_bytes(
|
|
timeout: u64,
|
|
bytes: Bytes,
|
|
) -> Result<Discovery, crate::error::Error> {
|
|
let discovery = ffmpeg::discover_bytes(timeout, bytes.clone()).await?;
|
|
|
|
let discovery = magick::confirm_bytes(discovery, timeout, bytes.clone()).await?;
|
|
|
|
let discovery = exiftool::check_reorient(discovery, timeout, bytes).await?;
|
|
|
|
Ok(discovery)
|
|
}
|