From a0313e52e3a0e9dac4d57da2663f313628d99d07 Mon Sep 17 00:00:00 2001 From: jb-alvarado Date: Sun, 10 Dec 2023 12:14:19 +0100 Subject: [PATCH] compare duration with tolerance, clean error message --- ffplayout-engine/src/input/playlist.rs | 6 +++--- lib/src/utils/json_validate.rs | 11 ++++++----- lib/src/utils/logging.rs | 2 +- lib/src/utils/mod.rs | 8 ++++---- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/ffplayout-engine/src/input/playlist.rs b/ffplayout-engine/src/input/playlist.rs index ba7978d0..1a5a58ba 100644 --- a/ffplayout-engine/src/input/playlist.rs +++ b/ffplayout-engine/src/input/playlist.rs @@ -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); diff --git a/lib/src/utils/json_validate.rs b/lib/src/utils/json_validate.rs index bb0350bc..8a45ed58 100644 --- a/lib/src/utils/json_validate.rs +++ b/lib/src/utils/json_validate.rs @@ -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: {}, file duration: {}, source {}", + if !is_close(o.duration, probe_duration, 1.2) { + error!( + "File duration differs from playlist value. File duration: {}, playlist value: {}, source {}", sec_to_time(o.duration), sec_to_time(probe_duration), o.source ); diff --git a/lib/src/utils/logging.rs b/lib/src/utils/logging.rs index e24c4c02..789c5aef 100644 --- a/lib/src/utils/logging.rs +++ b/lib/src/utils/logging.rs @@ -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!"); diff --git a/lib/src/utils/mod.rs b/lib/src/utils/mod.rs index e9356b97..6497456b 100644 --- a/lib/src/utils/mod.rs +++ b/lib/src/utils/mod.rs @@ -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(())