diff --git a/ffplayout-engine/src/output/null.rs b/ffplayout-engine/src/output/null.rs index 8e2d7b0d..9e4f6a0e 100644 --- a/ffplayout-engine/src/output/null.rs +++ b/ffplayout-engine/src/output/null.rs @@ -2,41 +2,31 @@ use std::process::{self, Command, Stdio}; use simplelog::*; -use ffplayout_lib::{filter::v_drawtext, utils::PlayoutConfig, vec_strings}; +use crate::utils::prepare_output_cmd; +use ffplayout_lib::{ + utils::{Media, PlayoutConfig, ProcessUnit::*}, + vec_strings, +}; /// Desktop Output /// /// Instead of streaming, we run a ffplay instance and play on desktop. pub fn output(config: &PlayoutConfig, log_format: &str) -> process::Child { - let mut enc_filter: Vec = vec![]; + let mut media = Media::new(0, "", false); + media.unit = Encoder; + media.add_filter(config, &None); - let mut enc_cmd = vec_strings![ + let enc_prefix = vec_strings![ "-hide_banner", "-nostats", "-v", log_format, "-re", "-i", - "pipe:0", - "-f", - "null", - "-" + "pipe:0" ]; - if config.text.add_text && !config.text.text_from_filename { - if let Some(socket) = config.text.zmq_stream_socket.clone() { - debug!( - "Using drawtext filter, listening on address: {}", - socket - ); - - let mut filter: String = "null,".to_string(); - filter.push_str(v_drawtext::filter_node(config, None, &None).as_str()); - enc_filter = vec!["-vf".to_string(), filter]; - } - } - - enc_cmd.splice(7..7, enc_filter); + let enc_cmd = prepare_output_cmd(enc_prefix, &media.filter, config); debug!( "Encoder CMD: \"ffmpeg {}\"", diff --git a/ffplayout-engine/src/output/stream.rs b/ffplayout-engine/src/output/stream.rs index 4b979499..29769c67 100644 --- a/ffplayout-engine/src/output/stream.rs +++ b/ffplayout-engine/src/output/stream.rs @@ -12,8 +12,6 @@ use ffplayout_lib::{ /// /// Prepare the ffmpeg command for streaming output pub fn output(config: &PlayoutConfig, log_format: &str) -> process::Child { - let mut enc_cmd = vec![]; - let mut output_cmd = config.out.output_cmd.as_ref().unwrap().clone(); let mut media = Media::new(0, "", false); media.unit = Encoder; media.add_filter(config, &None); @@ -28,8 +26,6 @@ pub fn output(config: &PlayoutConfig, log_format: &str) -> process::Child { "pipe:0" ]; - enc_cmd.append(&mut output_cmd); - let enc_cmd = prepare_output_cmd(enc_prefix, &media.filter, config); debug!( diff --git a/lib/src/utils/config.rs b/lib/src/utils/config.rs index a08a307e..20ff567b 100644 --- a/lib/src/utils/config.rs +++ b/lib/src/utils/config.rs @@ -9,8 +9,8 @@ use std::{ use serde::{Deserialize, Serialize}; use shlex::split; -use crate::utils::{free_tcp_socket, home_dir, time_to_sec}; -use crate::vec_strings; +use super::vec_strings; +use crate::utils::{free_tcp_socket, home_dir, time_to_sec, OutputMode::*}; pub const DUMMY_LEN: f64 = 60.0; pub const IMAGE_FORMAT: [&str; 21] = [ @@ -306,7 +306,12 @@ impl PlayoutConfig { config.processing.settings = Some(settings); config.ingest.input_cmd = split(config.ingest.input_param.as_str()); - config.out.output_cmd = split(config.out.output_param.as_str()); + + if config.out.mode == Null { + config.out.output_cmd = Some(vec_strings!["-f", "null", "-"]); + } else { + config.out.output_cmd = split(config.out.output_param.as_str()); + } // when text overlay without text_from_filename is on, turn also the RPC server on, // to get text messages from it