diff --git a/ffplayout-engine/src/utils/mod.rs b/ffplayout-engine/src/utils/mod.rs index 3aabf72f..95a6f362 100644 --- a/ffplayout-engine/src/utils/mod.rs +++ b/ffplayout-engine/src/utils/mod.rs @@ -152,11 +152,8 @@ pub fn prepare_output_cmd( let re_multi = Regex::new(r"\[[\w:_-]+\]\[[\w:_-]+\]").unwrap(); if let Some(mut filter) = filters.clone() { - // Loop over output parameters - // - // Check if it contains a filtergraph, count its outputs and set correct mapping values. + // Check if it contains a filtergraph and set correct output mapping. for (i, param) in output_params.iter().enumerate() { - // Skip filter command, to concat existing filters with new ones. if param != "-filter_complex" { if i > 0 && output_params[i - 1] == "-filter_complex" { output_filter = param.clone(); diff --git a/lib/src/filter/v_drawtext.rs b/lib/src/filter/v_drawtext.rs index 7700cec1..3d702a3a 100644 --- a/lib/src/filter/v_drawtext.rs +++ b/lib/src/filter/v_drawtext.rs @@ -1,4 +1,5 @@ use std::{ + ffi::OsStr, path::Path, sync::{Arc, Mutex}, }; @@ -27,11 +28,16 @@ pub fn filter_node( // TODO: in Rust 1.65 use let_chains instead if config.text.text_from_filename && node.is_some() { let source = node.unwrap_or(&Media::new(0, "", false)).source.clone(); - let regex: Regex = Regex::new(&config.text.regex).unwrap(); - - let text: String = match regex.captures(&source) { + let text = match Regex::new(&config.text.regex) + .ok() + .and_then(|r| r.captures(&source)) + { Some(t) => t[1].to_string(), - None => source, + None => Path::new(&source) + .file_stem() + .unwrap_or_else(|| OsStr::new(&source)) + .to_string_lossy() + .to_string(), }; let escape = text