Merge branch 'main' of github.com:jb-alvarado/ffplayout-rs

This commit is contained in:
jb-alvarado 2022-03-17 19:58:00 +01:00
commit 4e117af07b
3 changed files with 57 additions and 1 deletions

View File

@ -16,7 +16,8 @@ mod desktop;
mod stream;
use crate::utils::{
sec_to_time, stderr_reader, watch_folder, CurrentProgram, GlobalConfig, Media, Source,
ingest_server, sec_to_time, stderr_reader, watch_folder, CurrentProgram, GlobalConfig, Media,
Source,
};
pub fn play(rt_handle: &Handle) {
@ -74,6 +75,8 @@ pub fn play(rt_handle: &Handle) {
let mut buffer: [u8; 65424] = [0; 65424];
ingest_server(ff_log_format.clone());
for node in get_source {
let cmd = match node.cmd {
Some(cmd) => cmd,

51
src/utils/ingest.rs Normal file
View File

@ -0,0 +1,51 @@
use std::path::Path;
use simplelog::*;
use crate::utils::GlobalConfig;
fn overlay(config: &GlobalConfig) -> String {
let mut logo_chain = String::new();
if config.processing.add_logo && Path::new(&config.processing.logo).is_file() {
let opacity = format!(
"format=rgba,colorchannelmixer=aa={}",
config.processing.logo_opacity
);
let logo_loop = "loop=loop=-1:size=1:start=0";
logo_chain = format!("[v];movie={},{logo_loop},{opacity}", config.processing.logo);
logo_chain
.push_str(format!("[l];[v][l]{}:shortest=1", config.processing.logo_filter).as_str());
}
logo_chain
}
pub fn ingest_server(log_format: String) {
let config = GlobalConfig::global();
let mut filter = format!(
"[0:v]fps={},scale={}:{},'setdar=dar={}",
config.processing.fps,
config.processing.width,
config.processing.height,
config.processing.aspect
);
filter.push_str(&overlay(&config));
filter.push_str("[vout1]");
let mut filter_list = vec!["-filter_complex", &filter, "-map", "[vout1]", "-map", "0:a"];
let mut server_cmd = vec!["-hide_banner", "-nostats", "-v", log_format.as_str()];
let stream_input = config.ingest.stream_input.clone();
let stream_settings = config.processing.settings.clone().unwrap();
server_cmd.append(&mut stream_input.iter().map(String::as_str).collect());
server_cmd.append(&mut filter_list);
server_cmd.append(&mut stream_settings.iter().map(String::as_str).collect());
info!(
"Start ingest server, listening on: <b><magenta>{}</></b>",
stream_input.last().unwrap()
);
}

View File

@ -16,6 +16,7 @@ use simplelog::*;
mod arg_parse;
mod config;
mod folder;
mod ingest;
mod json_reader;
mod json_validate;
mod logging;
@ -23,6 +24,7 @@ mod playlist;
pub use arg_parse::get_args;
pub use config::{init_config, GlobalConfig};
pub use ingest::ingest_server;
pub use folder::{watch_folder, Source};
pub use json_reader::{read_json, DUMMY_LEN, Playlist};
pub use json_validate::validate_playlist;