fix pad filter, simpler source validation
This commit is contained in:
parent
a9dae4ee5b
commit
1af055dcfd
@ -74,23 +74,13 @@ fn deinterlace(field_order: &Option<String>, chain: &mut Filters) {
|
|||||||
|
|
||||||
fn pad(aspect: f64, chain: &mut Filters, config: &GlobalConfig) {
|
fn pad(aspect: f64, chain: &mut Filters, config: &GlobalConfig) {
|
||||||
if !is_close(aspect, config.processing.aspect, 0.03) {
|
if !is_close(aspect, config.processing.aspect, 0.03) {
|
||||||
if aspect < config.processing.aspect {
|
chain.add_filter(
|
||||||
chain.add_filter(
|
&format!(
|
||||||
&format!(
|
"pad=max(iw\\,ih*({0}/{1})):ow/({0}/{1}):(ow-iw)/2:(oh-ih)/2",
|
||||||
"pad=ih*{}/{}/sar:ih:(ow-iw)/2:(oh-ih)/2",
|
config.processing.width, config.processing.height
|
||||||
config.processing.width, config.processing.height
|
),
|
||||||
),
|
"video",
|
||||||
"video",
|
)
|
||||||
)
|
|
||||||
} else if aspect > config.processing.aspect {
|
|
||||||
chain.add_filter(
|
|
||||||
&format!(
|
|
||||||
"pad=iw:iw*{}/{}/sar:(ow-iw)/2:(oh-ih)/2",
|
|
||||||
config.processing.width, config.processing.height
|
|
||||||
),
|
|
||||||
"video",
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ use simplelog::*;
|
|||||||
|
|
||||||
use crate::utils::{
|
use crate::utils::{
|
||||||
check_sync, gen_dummy, get_delta, get_sec, is_close, json_serializer::read_json, modified_time,
|
check_sync, gen_dummy, get_delta, get_sec, is_close, json_serializer::read_json, modified_time,
|
||||||
seek_and_length, validate_source, GlobalConfig, Media, PlayoutStatus, DUMMY_LEN,
|
seek_and_length, valid_source, GlobalConfig, Media, PlayoutStatus, DUMMY_LEN,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Struct for current playlist.
|
/// Struct for current playlist.
|
||||||
@ -430,7 +430,7 @@ fn timed_source(
|
|||||||
|
|
||||||
/// Generate the source CMD, or when clip not exist, get a dummy.
|
/// Generate the source CMD, or when clip not exist, get a dummy.
|
||||||
fn gen_source(config: &GlobalConfig, mut node: Media) -> Media {
|
fn gen_source(config: &GlobalConfig, mut node: Media) -> Media {
|
||||||
if validate_source(&node.source) {
|
if valid_source(&node.source) {
|
||||||
node.add_probe();
|
node.add_probe();
|
||||||
node.cmd = Some(seek_and_length(
|
node.cmd = Some(seek_and_length(
|
||||||
node.source.clone(),
|
node.source.clone(),
|
||||||
@ -440,13 +440,13 @@ fn gen_source(config: &GlobalConfig, mut node: Media) -> Media {
|
|||||||
));
|
));
|
||||||
node.add_filter(config);
|
node.add_filter(config);
|
||||||
} else {
|
} else {
|
||||||
if node.source.chars().count() == 0 {
|
if node.source.is_empty() {
|
||||||
warn!(
|
warn!(
|
||||||
"Generate filler with <yellow>{:.2}</> seconds length!",
|
"Generate filler with <yellow>{:.2}</> seconds length!",
|
||||||
node.out - node.seek
|
node.out - node.seek
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
error!("File not found: <b><magenta>{}</></b>", node.source);
|
error!("Source not found: <b><magenta>{}</></b>", node.source);
|
||||||
}
|
}
|
||||||
let (source, cmd) = gen_dummy(config, node.out - node.seek);
|
let (source, cmd) = gen_dummy(config, node.out - node.seek);
|
||||||
node.source = source;
|
node.source = source;
|
||||||
|
@ -5,7 +5,7 @@ use std::sync::{
|
|||||||
|
|
||||||
use simplelog::*;
|
use simplelog::*;
|
||||||
|
|
||||||
use crate::utils::{sec_to_time, validate_source, GlobalConfig, MediaProbe, Playlist};
|
use crate::utils::{sec_to_time, valid_source, GlobalConfig, MediaProbe, Playlist};
|
||||||
|
|
||||||
/// Validate a given playlist, to check if:
|
/// Validate a given playlist, to check if:
|
||||||
///
|
///
|
||||||
@ -28,7 +28,7 @@ pub fn validate_playlist(playlist: Playlist, is_terminated: Arc<AtomicBool>, con
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if validate_source(&item.source) {
|
if valid_source(&item.source) {
|
||||||
let probe = MediaProbe::new(&item.source);
|
let probe = MediaProbe::new(&item.source);
|
||||||
|
|
||||||
if probe.format.is_none() {
|
if probe.format.is_none() {
|
||||||
@ -40,7 +40,7 @@ pub fn validate_playlist(playlist: Playlist, is_terminated: Arc<AtomicBool>, con
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
error!(
|
error!(
|
||||||
"File on position <yellow>{}</> not exists: <b><magenta>{}</></b>",
|
"Source on position <yellow>{}</> not exists: <b><magenta>{}</></b>",
|
||||||
sec_to_time(begin),
|
sec_to_time(begin),
|
||||||
item.source
|
item.source
|
||||||
);
|
);
|
||||||
|
@ -432,17 +432,11 @@ pub fn prepare_output_cmd(
|
|||||||
/// Validate input
|
/// Validate input
|
||||||
///
|
///
|
||||||
/// Check if input is a remote source, or from storage and see if it exists.
|
/// Check if input is a remote source, or from storage and see if it exists.
|
||||||
pub fn validate_source(source: &str) -> bool {
|
pub fn valid_source(source: &str) -> bool {
|
||||||
let re = Regex::new(r"^https?://.*").unwrap();
|
let re = Regex::new(r"^https?://.*").unwrap();
|
||||||
|
|
||||||
if re.is_match(source) {
|
if re.is_match(source) && MediaProbe::new(source).video_streams.is_some() {
|
||||||
match MediaProbe::new(source).video_streams {
|
return true;
|
||||||
Some(_) => return true,
|
|
||||||
None => {
|
|
||||||
error!("Remote file not exist: {source}");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Path::new(&source).is_file()
|
Path::new(&source).is_file()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user