Ensure that ffms2/lsmash exists if specified

This commit is contained in:
redzic 2021-11-23 08:01:43 -06:00
parent af87153259
commit 9897290f65
2 changed files with 24 additions and 2 deletions

View file

@ -1,3 +1,4 @@
use crate::vapoursynth::{is_ffms2_installed, is_lsmash_installed};
use crate::{
broker::{Broker, EncoderCrash},
chunk::Chunk,
@ -466,6 +467,19 @@ impl EncodeArgs {
properly into a mkv file. Specify mkvmerge as the concatenation method by setting `--concat mkvmerge`.");
}
if self.chunk_method == ChunkMethod::LSMASH {
ensure!(
is_lsmash_installed(),
"LSMASH is not installed, but it was specified as the chunk method"
);
}
if self.chunk_method == ChunkMethod::FFMS2 {
ensure!(
is_ffms2_installed(),
"FFMS2 is not installed, but it was specified as the chunk method"
);
}
if let Some(vmaf_path) = &self.vmaf_path {
ensure!(vmaf_path.exists());
}

View file

@ -35,10 +35,18 @@ static VAPOURSYNTH_PLUGINS: Lazy<HashSet<String>> = Lazy::new(|| {
.collect()
});
pub fn is_lsmash_installed() -> bool {
VAPOURSYNTH_PLUGINS.contains("systems.innocent.lsmas")
}
pub fn is_ffms2_installed() -> bool {
VAPOURSYNTH_PLUGINS.contains("com.vapoursynth.ffms2")
}
pub fn best_available_chunk_method() -> ChunkMethod {
if VAPOURSYNTH_PLUGINS.contains("systems.innocent.lsmas") {
if is_lsmash_installed() {
ChunkMethod::LSMASH
} else if VAPOURSYNTH_PLUGINS.contains("com.vapoursynth.ffms2") {
} else if is_ffms2_installed() {
ChunkMethod::FFMS2
} else {
ChunkMethod::Hybrid