reorder and cleanup
This commit is contained in:
parent
492085c9fd
commit
4a87655316
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -195,7 +195,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ffplayout-engine"
|
||||
version = "0.9.6"
|
||||
version = "0.9.7"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"clap",
|
||||
|
@ -4,7 +4,7 @@ description = "24/7 playout based on rust and ffmpeg"
|
||||
license = "GPL-3.0"
|
||||
authors = ["Jonathan Baecker jonbae77@gmail.com"]
|
||||
readme = "README.md"
|
||||
version = "0.9.6"
|
||||
version = "0.9.7"
|
||||
edition = "2021"
|
||||
default-run = "ffplayout"
|
||||
|
||||
|
@ -12,6 +12,30 @@ use crate::filter::ingest_filter::filter_cmd;
|
||||
use crate::utils::{format_log_line, GlobalConfig, Ingest, ProcessControl};
|
||||
use crate::vec_strings;
|
||||
|
||||
pub fn log_line(line: String, level: &str) {
|
||||
if line.contains("[info]") && level.to_lowercase() == "info" {
|
||||
info!(
|
||||
"<bright black>[Server]</> {}",
|
||||
format_log_line(line, "info")
|
||||
)
|
||||
} else if line.contains("[warning]")
|
||||
&& (level.to_lowercase() == "warning" || level.to_lowercase() == "info")
|
||||
{
|
||||
warn!(
|
||||
"<bright black>[Server]</> {}",
|
||||
format_log_line(line, "warning")
|
||||
)
|
||||
} else if line.contains("[error]")
|
||||
&& !line.contains("Input/output error")
|
||||
&& !line.contains("Broken pipe")
|
||||
{
|
||||
error!(
|
||||
"<bright black>[Server]</> {}",
|
||||
format_log_line(line, "error")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
fn server_monitor(
|
||||
level: &str,
|
||||
buffer: BufReader<ChildStderr>,
|
||||
@ -20,33 +44,18 @@ fn server_monitor(
|
||||
for line in buffer.lines() {
|
||||
let line = line?;
|
||||
|
||||
if line.contains("[info]") && level.to_lowercase() == "info" {
|
||||
info!(
|
||||
"<bright black>[Server]</> {}",
|
||||
format_log_line(line.clone(), "info")
|
||||
)
|
||||
} else if line.contains("[warning]")
|
||||
&& (level.to_lowercase() == "warning" || level.to_lowercase() == "info")
|
||||
{
|
||||
if line.contains("rtmp") && line.contains("Unexpected stream") {
|
||||
if let Err(e) = proc_ctl.kill(Ingest) {
|
||||
error!("{e}");
|
||||
};
|
||||
|
||||
warn!(
|
||||
"<bright black>[Server]</> {}",
|
||||
format_log_line(line.clone(), "warning")
|
||||
)
|
||||
} else if line.contains("[error]")
|
||||
&& !line.contains("Input/output error")
|
||||
&& !line.contains("Broken pipe")
|
||||
{
|
||||
error!(
|
||||
"<bright black>[Server]</> {}",
|
||||
format_log_line(line.clone(), "error")
|
||||
);
|
||||
}
|
||||
|
||||
if line.contains("rtmp") && line.contains("Unexpected stream") {
|
||||
if let Err(e) = proc_ctl.kill(Ingest) {
|
||||
error!("{e}");
|
||||
};
|
||||
}
|
||||
log_line(line, level);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
@ -28,10 +28,10 @@ use std::{
|
||||
use simplelog::*;
|
||||
|
||||
use crate::filter::ingest_filter::filter_cmd;
|
||||
use crate::input::source_generator;
|
||||
use crate::input::{ingest::log_line, source_generator};
|
||||
use crate::utils::{
|
||||
format_log_line, sec_to_time, stderr_reader, Decoder, GlobalConfig, Ingest, PlayerControl,
|
||||
PlayoutStatus, ProcessControl,
|
||||
sec_to_time, stderr_reader, Decoder, GlobalConfig, Ingest, PlayerControl, PlayoutStatus,
|
||||
ProcessControl,
|
||||
};
|
||||
use crate::vec_strings;
|
||||
|
||||
@ -42,6 +42,7 @@ fn ingest_to_hls_server(
|
||||
mut proc_control: ProcessControl,
|
||||
) -> Result<(), Error> {
|
||||
let playlist_init = playout_stat.list_init;
|
||||
let level = config.logging.ffmpeg_level.clone();
|
||||
|
||||
let mut server_cmd = vec_strings!["-hide_banner", "-nostats", "-v", "level+info"];
|
||||
let stream_input = config.ingest.input_cmd.clone().unwrap();
|
||||
@ -70,7 +71,7 @@ fn ingest_to_hls_server(
|
||||
{
|
||||
Err(e) => {
|
||||
error!("couldn't spawn ingest server: {e}");
|
||||
panic!("couldn't spawn ingest server: {e}")
|
||||
panic!("couldn't spawn ingest server: {e}");
|
||||
}
|
||||
Ok(proc) => proc,
|
||||
};
|
||||
@ -82,6 +83,12 @@ fn ingest_to_hls_server(
|
||||
for line in server_err.lines() {
|
||||
let line = line?;
|
||||
|
||||
if line.contains("rtmp") && line.contains("Unexpected stream") {
|
||||
if let Err(e) = proc_ctl.kill(Ingest) {
|
||||
error!("{e}");
|
||||
};
|
||||
}
|
||||
|
||||
if !is_running {
|
||||
proc_control.server_is_running.store(true, Ordering::SeqCst);
|
||||
playlist_init.store(true, Ordering::SeqCst);
|
||||
@ -94,21 +101,7 @@ fn ingest_to_hls_server(
|
||||
}
|
||||
}
|
||||
|
||||
if line.contains("[error]")
|
||||
&& !line.contains("Input/output error")
|
||||
&& !line.contains("Broken pipe")
|
||||
{
|
||||
error!(
|
||||
"<bright black>[server]</> {}",
|
||||
format_log_line(line.clone(), "error")
|
||||
);
|
||||
}
|
||||
|
||||
if line.contains("rtmp") && line.contains("Unexpected stream") {
|
||||
if let Err(e) = proc_ctl.kill(Ingest) {
|
||||
error!("{e}");
|
||||
};
|
||||
}
|
||||
log_line(line, &level);
|
||||
}
|
||||
|
||||
info!("Switch from live ingest to {}", config.processing.mode);
|
||||
|
Loading…
x
Reference in New Issue
Block a user