compare duration with tolerance, clean error message

This commit is contained in:
jb-alvarado 2023-12-10 12:14:19 +01:00
parent 6dbf95c47a
commit a0313e52e3
4 changed files with 14 additions and 13 deletions

View File

@ -601,7 +601,7 @@ pub fn gen_source(
trace!("Clip out: {duration}, duration: {}", node.duration);
if node.probe.is_none() {
if node.probe.is_none() && !node.source.is_empty() {
node.add_probe(true);
} else {
trace!("Node has a probe...")
@ -622,7 +622,7 @@ pub fn gen_source(
}
} else {
trace!(
"clip index: {:?} | last index: {:?}",
"clip index: {} | last index: {}",
node.index.unwrap_or_default(),
last_index
);
@ -718,7 +718,7 @@ pub fn gen_source(
}
}
Err(e) => {
error!("{e:?}");
error!("{e}");
// Create colored placeholder.
let (source, cmd) = gen_dummy(config, duration);

View File

@ -13,8 +13,9 @@ use simplelog::*;
use crate::filter::FilterType::Audio;
use crate::utils::{
errors::ProcError, loop_image, sec_to_time, seek_and_length, vec_strings, JsonPlaylist, Media,
OutputMode::Null, PlayerControl, PlayoutConfig, FFMPEG_IGNORE_ERRORS, IMAGE_FORMAT,
errors::ProcError, is_close, loop_image, sec_to_time, seek_and_length, vec_strings,
JsonPlaylist, Media, OutputMode::Null, PlayerControl, PlayoutConfig, FFMPEG_IGNORE_ERRORS,
IMAGE_FORMAT,
};
/// Validate a single media file.
@ -196,9 +197,9 @@ pub fn validate_playlist(
{
let probe_duration = dur.parse().unwrap_or_default();
if o.duration != probe_duration {
warn!(
"File duration differs from playlist value. Playlist value: <b><magenta>{}</></b>, file duration: <b><magenta>{}</></b>, source <yellow>{}</>",
if !is_close(o.duration, probe_duration, 1.2) {
error!(
"File duration differs from playlist value. File duration: <b><magenta>{}</></b>, playlist value: <b><magenta>{}</></b>, source <yellow>{}</>",
sec_to_time(o.duration), sec_to_time(probe_duration), o.source
);

View File

@ -57,7 +57,7 @@ pub fn send_mail(cfg: &PlayoutConfig, msg: String) {
// Send the mail
if let Err(e) = mailer.send(&mail) {
error!("Could not send mail: {:?}", e);
error!("Could not send mail: {e}");
}
} else {
error!("Mail Message failed!");

View File

@ -133,7 +133,7 @@ impl Media {
.parse()
.unwrap_or_default();
}
Err(e) => error!("{e:?}"),
Err(e) => error!("{e}"),
}
}
@ -178,7 +178,7 @@ impl Media {
}
}
}
Err(e) => error!("{e:?}"),
Err(e) => error!("{e}"),
};
if check_audio && Path::new(&self.audio).is_file() {
@ -194,7 +194,7 @@ impl Media {
.unwrap_or_default()
}
}
Err(e) => error!("{e:?}"),
Err(e) => error!("{e}"),
}
}
}
@ -774,7 +774,7 @@ fn ffmpeg_filter_and_libs(config: &mut PlayoutConfig) -> Result<(), String> {
}
if let Err(e) = ff_proc.wait() {
error!("{:?}", e)
error!("{e}")
};
Ok(())