pub enum DecodeError {
FileNotFound {
path: PathBuf,
},
NoVideoStream {
path: PathBuf,
},
NoAudioStream {
path: PathBuf,
},
UnsupportedCodec {
codec: String,
},
DecodingFailed {
timestamp: Option<Duration>,
reason: String,
},
SeekFailed {
target: Duration,
reason: String,
},
HwAccelUnavailable {
accel: HardwareAccel,
},
EndOfStream,
Ffmpeg {
code: i32,
message: String,
},
Io(Error),
}Expand description
Errors that can occur during decoding operations.
This enum covers all error conditions that may arise when opening, configuring, or decoding media files.
§Error Categories
- File errors:
FileNotFound - Stream errors:
NoVideoStream,NoAudioStream - Codec errors:
UnsupportedCodec - Runtime errors:
DecodingFailed,SeekFailed - Hardware errors:
HwAccelUnavailable - Stream state:
EndOfStream - Internal errors:
Ffmpeg,Io
Variants§
FileNotFound
File was not found at the specified path.
This error occurs when attempting to open a file that doesn’t exist.
NoVideoStream
No video stream exists in the media file.
This error occurs when trying to decode video from a file that only contains audio or other non-video streams.
NoAudioStream
No audio stream exists in the media file.
This error occurs when trying to decode audio from a file that only contains video or other non-audio streams.
UnsupportedCodec
The codec is not supported by this decoder.
This may occur for uncommon or proprietary codecs that are not
included in the FFmpeg build.
DecodingFailed
Decoding operation failed at a specific point.
This can occur due to corrupted data, unexpected stream format, or internal decoder errors.
Fields
SeekFailed
Seek operation failed.
Seeking may fail for various reasons including corrupted index, seeking beyond file bounds, or stream format limitations.
Requested hardware acceleration is not available.
This error occurs when a specific hardware accelerator is requested
but the system doesn’t support it. Consider using HardwareAccel::Auto
for automatic fallback.
EndOfStream
End of stream has been reached.
This is returned when attempting to decode past the end of the file. It’s a normal condition that indicates all frames have been decoded.
Ffmpeg
FFmpeg internal error.
This wraps errors from the underlying FFmpeg library that don’t
fit into other categories.
Fields
Io(Error)
I/O error during file operations.
This wraps standard I/O errors such as permission denied, disk full, or network errors for remote files.
Implementations§
Source§impl DecodeError
impl DecodeError
Sourcepub fn decoding_failed(reason: impl Into<String>) -> Self
pub fn decoding_failed(reason: impl Into<String>) -> Self
Creates a new DecodeError::DecodingFailed with the given reason.
§Arguments
reason- Description of why decoding failed.
§Examples
use ff_decode::DecodeError;
let error = DecodeError::decoding_failed("Corrupted frame data");
assert!(error.to_string().contains("Corrupted frame data"));
assert!(error.is_recoverable());Sourcepub fn decoding_failed_at(
timestamp: Duration,
reason: impl Into<String>,
) -> Self
pub fn decoding_failed_at( timestamp: Duration, reason: impl Into<String>, ) -> Self
Creates a new DecodeError::DecodingFailed with timestamp and reason.
§Arguments
timestamp- The timestamp where decoding failed.reason- Description of why decoding failed.
§Examples
use ff_decode::DecodeError;
use std::time::Duration;
let error = DecodeError::decoding_failed_at(
Duration::from_secs(30),
"Invalid packet size"
);
assert!(error.to_string().contains("30s"));
assert!(error.is_recoverable());Sourcepub fn seek_failed(target: Duration, reason: impl Into<String>) -> Self
pub fn seek_failed(target: Duration, reason: impl Into<String>) -> Self
Creates a new DecodeError::SeekFailed.
§Arguments
target- The target position of the failed seek.reason- Description of why the seek failed.
§Examples
use ff_decode::DecodeError;
use std::time::Duration;
let error = DecodeError::seek_failed(
Duration::from_secs(60),
"Index not found"
);
assert!(error.to_string().contains("60s"));
assert!(error.is_recoverable());Sourcepub fn ffmpeg(code: i32, message: impl Into<String>) -> Self
pub fn ffmpeg(code: i32, message: impl Into<String>) -> Self
Creates a new DecodeError::Ffmpeg.
§Arguments
code- The rawFFmpegerror code (negative integer). Pass0when no numeric code is available.message- Human-readable description of the error.
§Examples
use ff_decode::DecodeError;
let error = DecodeError::ffmpeg(-22, "Invalid data found when processing input");
assert!(error.to_string().contains("Invalid data"));
assert!(error.to_string().contains("code=-22"));Sourcepub fn is_eof(&self) -> bool
pub fn is_eof(&self) -> bool
Returns true if this error indicates end of stream.
§Examples
use ff_decode::DecodeError;
assert!(DecodeError::EndOfStream.is_eof());
assert!(!DecodeError::decoding_failed("test").is_eof());Sourcepub fn is_recoverable(&self) -> bool
pub fn is_recoverable(&self) -> bool
Returns true if this error is recoverable.
Recoverable errors are those where the decoder can continue operating after the error, such as corrupted frames that can be skipped.
§Examples
use ff_decode::DecodeError;
use std::time::Duration;
// Decoding failures are recoverable
assert!(DecodeError::decoding_failed("test").is_recoverable());
// Seek failures are recoverable
assert!(DecodeError::seek_failed(Duration::from_secs(1), "test").is_recoverable());
// End of stream is not recoverable
assert!(!DecodeError::EndOfStream.is_recoverable());Sourcepub fn is_fatal(&self) -> bool
pub fn is_fatal(&self) -> bool
Returns true if this error is fatal.
Fatal errors indicate that the decoder cannot continue and must be recreated or the file reopened.
§Examples
use ff_decode::DecodeError;
use std::path::PathBuf;
// File not found is fatal
assert!(DecodeError::FileNotFound { path: PathBuf::new() }.is_fatal());
// Unsupported codec is fatal
assert!(DecodeError::UnsupportedCodec { codec: "test".to_string() }.is_fatal());
// End of stream is not fatal
assert!(!DecodeError::EndOfStream.is_fatal());Trait Implementations§
Source§impl Debug for DecodeError
impl Debug for DecodeError
Source§impl Display for DecodeError
impl Display for DecodeError
Source§impl Error for DecodeError
impl Error for DecodeError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()