mirror of
https://github.com/spacedriveapp/spacedrive
synced 2024-07-04 12:13:27 +00:00
[ENG-828, ENG-633] Fix corrupt videos force crashing the app (#1028)
* fix corrupt videos crashing the app * fix typo * self-proclaimed genius
This commit is contained in:
parent
ac5f6323a5
commit
0dae7f7a63
|
@ -12,9 +12,9 @@ edition = { workspace = true }
|
|||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
ffmpeg-sys-next = "6.0.0"
|
||||
ffmpeg-sys-next = "6.0.1"
|
||||
|
||||
thiserror = "1.0.37"
|
||||
thiserror = "1.0.40"
|
||||
webp = "0.2.2"
|
||||
tokio = { workspace = true, features = ["fs", "rt"] }
|
||||
|
||||
|
|
|
@ -36,6 +36,10 @@ pub enum ThumbnailerError {
|
|||
InvalidQuality(f32),
|
||||
#[error("Background task failed: {0}")]
|
||||
BackgroundTaskFailed(#[from] JoinError),
|
||||
#[error("The video is most likely corrupt and will be skipped")]
|
||||
CorruptVideo,
|
||||
#[error("The video file contains subtitles and will be skipped")]
|
||||
Subtitles,
|
||||
}
|
||||
|
||||
/// Enum to represent possible errors from FFmpeg library
|
||||
|
|
|
@ -101,6 +101,17 @@ impl MovieDecoder {
|
|||
}
|
||||
}
|
||||
|
||||
unsafe {
|
||||
if (*decoder.format_context).probe_score == 100 {
|
||||
return Err(ThumbnailerError::CorruptVideo);
|
||||
}
|
||||
|
||||
// TODO(brxken128): idk if this is needed but i think so
|
||||
if (*decoder.format_context).subtitle_codec_id == AVCodecID::AV_CODEC_ID_NONE {
|
||||
return Err(ThumbnailerError::Subtitles);
|
||||
}
|
||||
}
|
||||
|
||||
decoder.initialize_video(prefer_embedded_metadata)?;
|
||||
|
||||
decoder.frame = unsafe { av_frame_alloc() };
|
||||
|
|
Loading…
Reference in a new issue