get list of filters and libs, #201 #219

This commit is contained in:
jb-alvarado 2022-11-27 21:11:40 +01:00
parent d30e6d7d61
commit 52856d3f09
6 changed files with 99 additions and 56 deletions

78
Cargo.lock generated
View File

@ -277,9 +277,9 @@ dependencies = [
[[package]]
name = "aho-corasick"
version = "0.7.19"
version = "0.7.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b4f55bd91a0978cbfd91c457a164bab8b4001c833b7f323132c0a4e1922dd44e"
checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac"
dependencies = [
"memchr",
]
@ -377,13 +377,13 @@ dependencies = [
[[package]]
name = "async-io"
version = "1.10.0"
version = "1.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8121296a9f05be7f34aa4196b1747243b3b62e048bb7906f644f3fbfc490cf7"
checksum = "8c374dda1ed3e7d8f0d9ba58715f924862c63eae6849c92d3a18e7fbde9e2794"
dependencies = [
"async-lock",
"autocfg",
"concurrent-queue 1.2.4",
"concurrent-queue 2.0.0",
"futures-lite",
"libc",
"log",
@ -392,7 +392,7 @@ dependencies = [
"slab",
"socket2",
"waker-fn",
"winapi 0.3.9",
"windows-sys 0.42.0",
]
[[package]]
@ -532,16 +532,16 @@ dependencies = [
[[package]]
name = "blocking"
version = "1.2.0"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c6ccb65d468978a086b69884437ded69a90faab3bbe6e67f242173ea728acccc"
checksum = "3c67b173a56acffd6d2326fb7ab938ba0b00a71480e14902b2591c87bc5741e8"
dependencies = [
"async-channel",
"async-lock",
"async-task",
"atomic-waker",
"fastrand",
"futures-lite",
"once_cell",
]
[[package]]
@ -588,9 +588,9 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610"
[[package]]
name = "bytes"
version = "1.2.1"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec8a7b6a70fde80372154c65702f00a0f56f3e1c36abbc6c440484be248856db"
checksum = "dfb24e866b15a1af2a1b663f10c6b6b8f397a84aadb828f12e5b289ec23a3a3c"
[[package]]
name = "bytestring"
@ -609,9 +609,9 @@ checksum = "c1db59621ec70f09c5e9b597b220c7a2b43611f4710dc03ceb8748637775692c"
[[package]]
name = "cc"
version = "1.0.76"
version = "1.0.77"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "76a284da2e6fe2092f2353e51713435363112dfd60030e22add80be333fb928f"
checksum = "e9f73505338f7d905b19d18738976aae232eb46b8efc15554ffc56deb5d9ebe4"
dependencies = [
"jobserver",
]
@ -638,7 +638,7 @@ dependencies = [
"js-sys",
"num-integer",
"num-traits",
"time 0.1.44",
"time 0.1.45",
"wasm-bindgen",
"winapi 0.3.9",
]
@ -788,9 +788,9 @@ dependencies = [
[[package]]
name = "crossbeam-queue"
version = "0.3.6"
version = "0.3.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1cd42583b04998a5363558e5f9291ee5a5ff6b49944332103f251e7479a82aa7"
checksum = "d1cfb3ea8a53f37c40dea2c7bedcbd88bdfae54f5e2175d6ecaff1c988353add"
dependencies = [
"cfg-if 1.0.0",
"crossbeam-utils",
@ -798,9 +798,9 @@ dependencies = [
[[package]]
name = "crossbeam-utils"
version = "0.8.12"
version = "0.8.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "edbafec5fa1f196ca66527c1b12c2ec4745ca14b50f1ad8f9f6f720b55d11fac"
checksum = "4fb766fa798726286dbbb842f174001dab8abc7b627a1dd86e0b7222a95d929f"
dependencies = [
"cfg-if 1.0.0",
]
@ -971,7 +971,7 @@ dependencies = [
[[package]]
name = "ffplayout"
version = "0.16.4"
version = "0.17.0"
dependencies = [
"chrono",
"clap",
@ -1022,7 +1022,7 @@ dependencies = [
[[package]]
name = "ffplayout-lib"
version = "0.16.4"
version = "0.17.0"
dependencies = [
"chrono",
"crossbeam-channel",
@ -1080,9 +1080,9 @@ dependencies = [
[[package]]
name = "flate2"
version = "1.0.24"
version = "1.0.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f82b0f4c27ad9f8bfd1f3208d882da2b09c301bc1c828fd3a00d0216d2fbbff6"
checksum = "a8a2db397cb1c8772f31494cb8917e48cd1e64f0fa7efac59fbd741a0a8ce841"
dependencies = [
"crc32fast",
"miniz_oxide",
@ -1841,9 +1841,9 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
[[package]]
name = "miniz_oxide"
version = "0.5.4"
version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "96590ba8f175222643a85693f33d26e9c8a015f599c216509b1a6894af675d34"
checksum = "b275950c28b37e794e8c55d88aeb5e139d0ce23fdbbeda68f8d7174abdf9e8fa"
dependencies = [
"adler",
]
@ -2017,9 +2017,9 @@ checksum = "86f0b0d4bf799edbc74508c1e8bf170ff5f41238e5f8225603ca7caaae2b7860"
[[package]]
name = "openssl"
version = "0.10.42"
version = "0.10.43"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "12fc0523e3bd51a692c8850d075d74dc062ccf251c0110668cbd921917118a13"
checksum = "020433887e44c27ff16365eaa2d380547a94544ad509aff6eb5b6e3e0b27b376"
dependencies = [
"bitflags",
"cfg-if 1.0.0",
@ -2058,9 +2058,9 @@ dependencies = [
[[package]]
name = "openssl-sys"
version = "0.9.77"
version = "0.9.78"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b03b84c3b2d099b81f0953422b4d4ad58761589d0229b5506356afca05a3670a"
checksum = "07d5c8cb6e57b3a3612064d7b18b117912b4ce70955c2504d4b741c9e244b132"
dependencies = [
"autocfg",
"cc",
@ -2072,9 +2072,9 @@ dependencies = [
[[package]]
name = "os_str_bytes"
version = "6.4.0"
version = "6.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b5bf27447411e9ee3ff51186bf7a08e16c341efdde93f4d823e8844429bed7e"
checksum = "9b7820b9daea5457c9f21c69448905d723fbd21136ccf521748f23fd49e723ee"
[[package]]
name = "paris"
@ -2208,16 +2208,16 @@ checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160"
[[package]]
name = "polling"
version = "2.4.0"
version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ab4609a838d88b73d8238967b60dd115cc08d38e2bbaf51ee1e4b695f89122e2"
checksum = "9f7d73f1eaed1ca1fb37b54dcc9b38e3b17d6c7b8ecb7abfffcac8d0351f17d4"
dependencies = [
"autocfg",
"cfg-if 1.0.0",
"libc",
"log",
"wepoll-ffi",
"winapi 0.3.9",
"windows-sys 0.42.0",
]
[[package]]
@ -2516,9 +2516,9 @@ dependencies = [
[[package]]
name = "serde_json"
version = "1.0.88"
version = "1.0.89"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e8b3801309262e8184d9687fb697586833e939767aea0dda89f5a8e650e8bd7"
checksum = "020ff22c755c2ed3f8cf162dbb41a7268d934702f3ed3631656ea597e08fc3db"
dependencies = [
"itoa",
"ryu",
@ -2855,9 +2855,9 @@ dependencies = [
[[package]]
name = "time"
version = "0.1.44"
version = "0.1.45"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255"
checksum = "1b797afad3f312d1c66a56d11d0316f916356d11bd158fbc6ca6389ff6bf805a"
dependencies = [
"libc",
"wasi 0.10.0+wasi-snapshot-preview1",
@ -3468,9 +3468,9 @@ dependencies = [
[[package]]
name = "zstd-sys"
version = "2.0.1+zstd.1.5.2"
version = "2.0.3+zstd.1.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9fd07cbbc53846d9145dbffdf6dd09a7a0aa52be46741825f5c97bdd4f73f12b"
checksum = "44ccf97612ac95f3ccb89b2d7346b345e52f1c3019be4984f0455fb4ba991f8a"
dependencies = [
"cc",
"libc",

View File

@ -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.16.4"
version = "0.17.0"
edition = "2021"
default-run = "ffplayout"

View File

@ -88,8 +88,7 @@ fn main() {
#[cfg(debug_assertions)]
fake_time(&args);
let config = get_config(args.clone());
let config_clone = config.clone();
let mut config = get_config(args.clone());
let play_control = PlayerControl::new();
let playout_stat = PlayoutStatus::new();
let proc_control = ProcessControl::new();
@ -102,11 +101,13 @@ fn main() {
let logging = init_logging(&config, Some(proc_ctl1), Some(messages.clone()));
CombinedLogger::init(logging).unwrap();
if let Err(e) = validate_ffmpeg(&config) {
if let Err(e) = validate_ffmpeg(&mut config) {
error!("{e}");
exit(1);
};
let config_clone = config.clone();
if ![2, 4, 6, 8].contains(&config.processing.audio_channels) {
error!(
"Encoding {} channel(s) is not allowed. Only 2, 4, 6 and 8 channels are supported!",

View File

@ -4,7 +4,7 @@ description = "Library for ffplayout"
license = "GPL-3.0"
authors = ["Jonathan Baecker jonbae77@gmail.com"]
readme = "README.md"
version = "0.16.4"
version = "0.17.0"
edition = "2021"
[dependencies]

View File

@ -110,6 +110,12 @@ pub struct General {
#[serde(skip_serializing, skip_deserializing)]
pub stat_file: String,
#[serde(skip_serializing, skip_deserializing)]
pub ffmpeg_filters: Vec<String>,
#[serde(skip_serializing, skip_deserializing)]
pub ffmpeg_libs: Vec<String>,
}
#[derive(Debug, Serialize, Deserialize, Clone)]

View File

@ -693,16 +693,30 @@ fn is_in_system(name: &str) -> Result<(), String> {
Ok(())
}
fn ffmpeg_libs() -> Result<Vec<String>, String> {
let mut libs: Vec<String> = vec![];
fn ffmpeg_filter_and_libs(config: &mut PlayoutConfig) -> Result<(), String> {
let ignore_flags = [
"--enable-gpl",
"--enable-version3",
"--enable-runtime-cpudetect",
"--enable-avfilter",
"--enable-zlib",
"--enable-pic",
"--enable-nonfree",
];
let mut ff_proc = match Command::new("ffmpeg").stderr(Stdio::piped()).spawn() {
let mut ff_proc = match Command::new("ffmpeg")
.args(["-filters"])
.stdout(Stdio::piped())
.stderr(Stdio::piped())
.spawn()
{
Err(e) => {
return Err(format!("couldn't spawn ffmpeg process: {e}"));
}
Ok(proc) => proc,
};
let out_buffer = BufReader::new(ff_proc.stdout.take().unwrap());
let err_buffer = BufReader::new(ff_proc.stderr.take().unwrap());
// stderr shows only the ffmpeg configuration
@ -711,26 +725,44 @@ fn ffmpeg_libs() -> Result<Vec<String>, String> {
if line.contains("configuration:") {
let configs = line.split_whitespace();
for config in configs {
if config.contains("--enable-lib") {
libs.push(config.replace("--enable-", ""));
for flag in configs {
if flag.contains("--enable") && !ignore_flags.contains(&flag) {
config
.general
.ffmpeg_libs
.push(flag.replace("--enable-", ""));
}
}
break;
}
}
// stdout shows filter from ffmpeg
// get filters
for line in out_buffer.lines().flatten() {
if line.contains('>') {
let filter_line = line.split_whitespace().collect::<Vec<_>>();
if filter_line.len() > 2 {
config
.general
.ffmpeg_filters
.push(filter_line[1].to_string())
}
}
}
if let Err(e) = ff_proc.wait() {
error!("{:?}", e)
};
Ok(libs)
Ok(())
}
/// Validate ffmpeg/ffprobe/ffplay.
///
/// Check if they are in system and has all libs and codecs we need.
pub fn validate_ffmpeg(config: &PlayoutConfig) -> Result<(), String> {
pub fn validate_ffmpeg(config: &mut PlayoutConfig) -> Result<(), String> {
is_in_system("ffmpeg")?;
is_in_system("ffprobe")?;
@ -738,15 +770,15 @@ pub fn validate_ffmpeg(config: &PlayoutConfig) -> Result<(), String> {
is_in_system("ffplay")?;
}
let libs = ffmpeg_libs()?;
ffmpeg_filter_and_libs(config)?;
if !libs.contains(&"libx264".to_string()) {
if !config.general.ffmpeg_libs.contains(&"libx264".to_string()) {
return Err("ffmpeg contains no libx264!".to_string());
}
if config.text.add_text
&& !config.text.text_from_filename
&& !libs.contains(&"libzmq".to_string())
&& !config.general.ffmpeg_libs.contains(&"libzmq".to_string())
{
return Err(
"ffmpeg contains no libzmq! Disable add_text in config or compile ffmpeg with libzmq."
@ -754,7 +786,11 @@ pub fn validate_ffmpeg(config: &PlayoutConfig) -> Result<(), String> {
);
}
if !libs.contains(&"libfdk-aac".to_string()) {
if !config
.general
.ffmpeg_libs
.contains(&"libfdk-aac".to_string())
{
warn!("ffmpeg contains no libfdk-aac! Can't use high quality aac encoder...");
}