use shlex for old config format: string instead of list
This commit is contained in:
parent
cbf4306d82
commit
ca616e9006
@ -11,17 +11,17 @@ file-rotate = "0.6.0"
|
||||
lettre = "0.10.0-rc.4"
|
||||
log = "0.4.14"
|
||||
notify = "4.0.17"
|
||||
rand = "0.8.5"
|
||||
regex = "1"
|
||||
once_cell = "1.10"
|
||||
process_control = "3.3"
|
||||
rand = "0.8.5"
|
||||
regex = "1"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = "1.0"
|
||||
serde_yaml = "0.8"
|
||||
shlex = "1.1"
|
||||
simplelog = { version = "^0.11.2", features = ["paris"] }
|
||||
tokio = { version = "1.16.1", features = ["rt-multi-thread"] }
|
||||
walkdir = "2"
|
||||
shlex = "1.1"
|
||||
|
||||
[target.x86_64-unknown-linux-musl.dependencies]
|
||||
openssl = { version = "0.10", features = ["vendored"] }
|
||||
|
@ -65,7 +65,7 @@ ingest:
|
||||
There is no authentication, this is up to you. The recommend way is to set address to
|
||||
localhost, stream to a local server with authentication and from there stream to this app.
|
||||
enable: false
|
||||
stream_input: [-f, live_flv, -listen, 1, -i, rtmp://localhost:1936/live/stream]
|
||||
input_param: -f live_flv -listen 1 -i rtmp://localhost:1936/live/stream
|
||||
|
||||
playlist:
|
||||
helptext: >
|
||||
@ -116,34 +116,34 @@ out:
|
||||
inside. 'preview' works only in streaming output and creates a separate preview stream.
|
||||
mode: 'stream'
|
||||
preview: false
|
||||
preview_param:
|
||||
[-s, 512x288,
|
||||
-c:v, libx264,
|
||||
-crf, 24,
|
||||
-x264-params, keyint=50:min-keyint=25:scenecut=-1,
|
||||
-maxrate, 800k,
|
||||
-bufsize, 1600k,
|
||||
-preset, ultrafast,
|
||||
-tune, zerolatency,
|
||||
-profile:v, Main,
|
||||
-level, 3.1,
|
||||
-c:a, aac,
|
||||
-ar, 44100,
|
||||
-b:a, 128k,
|
||||
-flags, +global_header,
|
||||
-f, flv, rtmp://preview.local/live/stream]
|
||||
stream_param:
|
||||
[-c:v, libx264,
|
||||
-crf, 23,
|
||||
-x264-params, keyint=50:min-keyint=25:scenecut=-1,
|
||||
-maxrate, 1300k,
|
||||
-bufsize, 2600k,
|
||||
-preset, faster,
|
||||
-tune, zerolatency,
|
||||
-profile:v, Main,
|
||||
-level, 3.1,
|
||||
-c:a, aac,
|
||||
-ar, 44100,
|
||||
-b:a, 128k,
|
||||
-flags, +global_header,
|
||||
-f, flv, rtmp://localhost/live/stream]
|
||||
preview_param: >-
|
||||
-s 512x288
|
||||
-c:v libx264
|
||||
-crf 24
|
||||
-x264-params keyint=50:min-keyint=25:scenecut=-1
|
||||
-maxrate 800k
|
||||
-bufsize 1600k
|
||||
-preset ultrafast
|
||||
-tune zerolatency
|
||||
-profile:v Main
|
||||
-level 3.1
|
||||
-c:a aac
|
||||
-ar 44100
|
||||
-b:a 128k
|
||||
-flags +global_header
|
||||
-f flv rtmp://preview.local/live/stream
|
||||
output_param: >-
|
||||
-c:v libx264
|
||||
-crf 23
|
||||
-x264-params keyint=50:min-keyint=25:scenecut=-1
|
||||
-maxrate 1300k
|
||||
-bufsize 2600k
|
||||
-preset faster
|
||||
-tune zerolatency
|
||||
-profile:v Main
|
||||
-level 3.1
|
||||
-c:a aac
|
||||
-ar 44100
|
||||
-b:a 128k
|
||||
-flags +global_header
|
||||
-f flv rtmp://localhost/live/stream
|
||||
|
@ -84,7 +84,7 @@ pub async fn ingest_server(
|
||||
];
|
||||
|
||||
let mut server_cmd = vec!["-hide_banner", "-nostats", "-v", log_format.as_str()];
|
||||
let stream_input = config.ingest.stream_input.clone();
|
||||
let stream_input = config.ingest.input_cmd.clone().unwrap();
|
||||
let stream_settings = config.processing.settings.clone().unwrap();
|
||||
|
||||
server_cmd.append(&mut stream_input.iter().map(String::as_str).collect());
|
||||
|
@ -5,13 +5,15 @@ use std::{
|
||||
|
||||
use simplelog::*;
|
||||
|
||||
use crate::utils::{GlobalConfig, Media};
|
||||
use crate::filter::v_drawtext;
|
||||
use crate::utils::{GlobalConfig, Media};
|
||||
|
||||
pub fn output(log_format: String) -> process::Child {
|
||||
let config = GlobalConfig::global();
|
||||
let mut enc_filter: Vec<String> = vec![];
|
||||
let mut preview: Vec<&str> = vec![];
|
||||
let preview_cmd = config.out.preview_cmd.as_ref().unwrap().clone();
|
||||
let output_cmd = config.out.output_cmd.as_ref().unwrap().clone();
|
||||
|
||||
let mut enc_cmd = vec![
|
||||
"-hide_banner",
|
||||
@ -36,18 +38,18 @@ pub fn output(log_format: String) -> process::Child {
|
||||
filter.push_str(",split=2[v_out1][v_out2]");
|
||||
|
||||
preview = vec!["-map", "[v_out1]", "-map", "0:a"];
|
||||
preview.append(&mut config.out.preview_param.iter().map(String::as_str).collect());
|
||||
preview.append(&mut preview_cmd.iter().map(String::as_str).collect());
|
||||
preview.append(&mut vec!["-map", "[v_out2]", "-map", "0:a"]);
|
||||
}
|
||||
|
||||
enc_filter = vec!["-filter_complex".to_string(), filter];
|
||||
} else if config.out.preview {
|
||||
preview = config.out.preview_param.iter().map(String::as_str).collect()
|
||||
preview = preview_cmd.iter().map(String::as_str).collect()
|
||||
}
|
||||
|
||||
enc_cmd.append(&mut enc_filter.iter().map(String::as_str).collect());
|
||||
enc_cmd.append(&mut preview);
|
||||
enc_cmd.append(&mut config.out.stream_param.iter().map(String::as_str).collect());
|
||||
enc_cmd.append(&mut output_cmd.iter().map(String::as_str).collect());
|
||||
|
||||
debug!("Encoder CMD: <bright-blue>{:?}</>", enc_cmd);
|
||||
|
||||
|
@ -8,6 +8,8 @@ use std::{
|
||||
process,
|
||||
};
|
||||
|
||||
use shlex::split;
|
||||
|
||||
use crate::utils::{get_args, time_to_sec};
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
@ -73,7 +75,8 @@ pub struct Processing {
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
pub struct Ingest {
|
||||
pub enable: bool,
|
||||
pub stream_input: Vec<String>,
|
||||
input_param: String,
|
||||
pub input_cmd: Option<Vec<String>>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
@ -109,8 +112,10 @@ pub struct Text {
|
||||
pub struct Out {
|
||||
pub mode: String,
|
||||
pub preview: bool,
|
||||
pub preview_param: Vec<String>,
|
||||
pub stream_param: Vec<String>,
|
||||
preview_param: String,
|
||||
pub preview_cmd: Option<Vec<String>>,
|
||||
output_param: String,
|
||||
pub output_cmd: Option<Vec<String>>,
|
||||
}
|
||||
|
||||
static INSTANCE: OnceCell<GlobalConfig> = OnceCell::new();
|
||||
@ -184,6 +189,10 @@ impl GlobalConfig {
|
||||
|
||||
config.processing.settings = Some(settings);
|
||||
|
||||
config.ingest.input_cmd = split(config.ingest.input_param.as_str());
|
||||
config.out.preview_cmd = split(config.out.preview_param.as_str());
|
||||
config.out.output_cmd = split(config.out.output_param.as_str());
|
||||
|
||||
if args.log.is_some() {
|
||||
config.logging.log_path = args.log.unwrap();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user