feat(probe): ffprobe wrapper
ci / web (pull_request) Successful in 8s
ci / rust (pull_request) Successful in 1m59s
e2e / e2e (pull_request) Successful in 1m40s

Post-download truth for DESIGN.md §5.6: resolution, codec, HDR with the
Dolby Vision profile as a number, per-track audio language plus the title
and handler_name strings §5.2 needs, subtitles, duration and size.

Also picks the feature file out of a multi-file torrent — largest video
file, checked against the expected runtime so an extras reel does not get
imported as the film.

The fixture clips are generated by scripts/make-probe-fixtures.sh. The two
Dolby Vision ones splice a dvcC/dvvC box into a real HEVC clip, since x265
will not encode DV without an RPU.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Miguel Palhas
2026-08-22 20:33:57 +01:00
co-authored by Claude Opus 5
parent 6a8051c70f
commit 3927927466
16 changed files with 1254 additions and 2 deletions
+97
View File
@@ -0,0 +1,97 @@
//! Errors the `ffprobe` wrapper can produce.
use std::path::PathBuf;
/// Result alias for every fallible operation in this crate.
pub type Result<T> = std::result::Result<T, Error>;
/// Everything that can go wrong probing a file.
///
/// Nothing here has a default. A file `ffprobe` cannot read is an error, never
/// a `ProbedFile` full of zeroes — importing on top of a default-valued struct
/// would silently record a 0-byte SDR file with no audio and pass every policy
/// rule that inspects a field it does not have (DESIGN.md §5.6, §5.7).
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum Error {
/// `ffprobe` could not be started at all: not installed, or not on `PATH`.
#[error("could not run {binary}")]
Spawn {
/// The binary that was attempted.
binary: String,
/// The underlying spawn failure.
#[source]
source: std::io::Error,
},
/// `ffprobe` started but exited non-zero — an unreadable or corrupt file.
#[error("ffprobe rejected {path}: {stderr}")]
Rejected {
/// The file that was probed.
path: PathBuf,
/// Exit status, absent when the process was killed by a signal.
status: Option<i32>,
/// `ffprobe`'s own diagnostics, truncated to something loggable.
stderr: String,
},
/// `ffprobe` did not finish within the configured timeout.
#[error("ffprobe timed out probing {path}")]
Timeout {
/// The file that was probed.
path: PathBuf,
},
/// Reading the child process failed after it was spawned.
#[error("reading ffprobe output for {path} failed")]
Io {
/// The file that was probed.
path: PathBuf,
/// The underlying IO failure.
#[source]
source: std::io::Error,
},
/// `ffprobe` printed something that is not the JSON shape expected.
#[error("ffprobe output for {path} did not parse")]
Decode {
/// The file that was probed.
path: PathBuf,
/// The deserialisation failure.
#[source]
source: serde_json::Error,
},
/// `ffprobe` read the file, but as a still image or as text.
///
/// ffmpeg's `tty` demuxer parses any text file at all as ANSI art video,
/// and the image demuxers turn a poster into a one-frame film. Both would
/// otherwise pass for importable media.
#[error("{path} is not a video file: ffprobe read it as {format}")]
NotVideo {
/// The file that was probed.
path: PathBuf,
/// The container format `ffprobe` matched.
format: String,
},
/// `ffprobe` read the file but it carries no video stream.
#[error("{path} has no video stream")]
NoVideoStream {
/// The file that was probed.
path: PathBuf,
},
/// A container that reports neither a duration nor a stream long enough to
/// derive one. The runtime sanity check has nothing to work with.
#[error("{path} reports no duration")]
NoDuration {
/// The file that was probed.
path: PathBuf,
},
/// Feature selection was handed a set of paths with no readable video file
/// among them.
#[error("no video file among the candidates")]
NoCandidates,
}