ez_ffmpeg/core/frame_export/error.rs
1//! Typed errors for frame export.
2//!
3//! These surface either from `FrameExtractor::frames()` / `SampleExtractor::samples()`
4//! (option validation and stream/duration/HDR resolution, before any worker
5//! thread starts) or as the iterator's single terminal error (runtime failures).
6//! They reach the public [`crate::error::Error`] through the
7//! [`crate::error::Error::FrameExport`] variant.
8
9use thiserror::Error;
10
11/// Something wrong with a frame-export request or run.
12#[derive(Error, Debug)]
13#[non_exhaustive]
14pub enum FrameExportError {
15 /// The input has no video stream to export from.
16 #[error("input has no video stream")]
17 NoVideoStream,
18
19 /// An explicit `video_stream_index` was out of range.
20 #[error("video stream index {index} out of bounds: input has {count} stream(s)")]
21 StreamIndexOutOfBounds {
22 /// The requested (out-of-range) index.
23 index: usize,
24 /// The number of streams the input actually has.
25 count: usize,
26 },
27
28 /// An explicit `video_stream_index` referred to a non-video stream.
29 #[error("stream {index} is not a video stream")]
30 NotAVideoStream {
31 /// The requested index.
32 index: usize,
33 },
34
35 /// `UniformN` needs a duration, and none could be resolved.
36 #[error("UniformN needs a resolvable duration; use duration_hint_us() or EverySec instead")]
37 UnknownDuration,
38
39 /// The input is HDR (BT.2020 / PQ / HLG). Tone mapping is a documented
40 /// non-goal of this module.
41 #[error(
42 "HDR input (BT.2020 / PQ / HLG) requires tone mapping, which frame export does not do yet"
43 )]
44 HdrRequiresToneMapping,
45
46 /// `UniformN(n)` was requested but the video stream produced no frames.
47 #[error("UniformN({n}) on a video stream that produced no frames")]
48 EmptyVideoStream {
49 /// The requested exact frame count.
50 n: u32,
51 },
52
53 /// An option value was invalid (zero count, zero size, non-finite seconds, …).
54 #[error("invalid frame-export option: {0}")]
55 InvalidOption(String),
56
57 /// The input has no audio stream to export from.
58 #[error("input has no audio stream")]
59 NoAudioStream,
60
61 /// An explicit `audio_stream_index` was out of range.
62 #[error("audio stream index {index} out of bounds: input has {count} stream(s)")]
63 AudioStreamIndexOutOfBounds {
64 /// The requested (out-of-range) index.
65 index: usize,
66 /// The number of streams the input actually has.
67 count: usize,
68 },
69
70 /// An explicit `audio_stream_index` referred to a non-audio stream.
71 #[error("stream {index} is not an audio stream")]
72 NotAnAudioStream {
73 /// The requested index.
74 index: usize,
75 },
76}