only seek in when by values over 0.5, use only realtime video filter, fix #198
This commit is contained in:
parent
2ebb4c6822
commit
9d094d9838
@ -8,7 +8,6 @@ use simplelog::*;
|
||||
pub mod a_loudnorm;
|
||||
pub mod custom_filter;
|
||||
pub mod v_drawtext;
|
||||
pub mod v_overlay;
|
||||
|
||||
use crate::utils::{fps_calc, get_delta, is_close, Media, MediaProbe, PlayoutConfig};
|
||||
|
||||
@ -171,7 +170,10 @@ fn overlay(node: &mut Media, chain: &mut Filters, config: &PlayoutConfig) {
|
||||
&& Path::new(&config.processing.logo).is_file()
|
||||
&& &node.category != "advertisement"
|
||||
{
|
||||
let mut logo_chain = v_overlay::filter_node(config);
|
||||
let mut logo_chain = format!(
|
||||
"null[v];movie={}:loop=0,setpts=N/(FRAME_RATE*TB),format=rgba,colorchannelmixer=aa={}[l];[v][l]{}:shortest=1",
|
||||
config.processing.logo, config.processing.logo_opacity, config.processing.logo_filter
|
||||
);
|
||||
|
||||
if node.last_ad.unwrap_or(false) {
|
||||
logo_chain.push_str(",fade=in:st=0:d=1.0:alpha=1")
|
||||
@ -287,20 +289,9 @@ fn aspect_calc(aspect_string: &Option<String>, config: &PlayoutConfig) -> f64 {
|
||||
}
|
||||
|
||||
/// This realtime filter is important for HLS output to stay in sync.
|
||||
fn realtime_filter(
|
||||
node: &mut Media,
|
||||
chain: &mut Filters,
|
||||
config: &PlayoutConfig,
|
||||
codec_type: FilterType,
|
||||
) {
|
||||
fn realtime_filter(node: &mut Media, chain: &mut Filters, config: &PlayoutConfig) {
|
||||
if config.general.generate.is_none() && &config.out.mode.to_lowercase() == "hls" {
|
||||
let mut t = "";
|
||||
|
||||
if codec_type == Audio {
|
||||
t = "a"
|
||||
}
|
||||
|
||||
let mut speed_filter = format!("{t}realtime=speed=1");
|
||||
let mut speed_filter = "realtime=speed=1".to_string();
|
||||
|
||||
if let Some(begin) = &node.begin {
|
||||
let (delta, _) = get_delta(config, begin);
|
||||
@ -310,12 +301,12 @@ fn realtime_filter(
|
||||
let speed = duration / (duration + delta);
|
||||
|
||||
if speed > 0.0 && speed < 1.1 && delta < config.general.stop_threshold {
|
||||
speed_filter = format!("{t}realtime=speed={speed}");
|
||||
speed_filter = format!("realtime=speed={speed}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
chain.add_filter(&speed_filter, codec_type);
|
||||
chain.add_filter(&speed_filter, Video);
|
||||
}
|
||||
}
|
||||
|
||||
@ -371,12 +362,11 @@ pub fn filter_chains(
|
||||
add_text(node, &mut filters, config, filter_chain);
|
||||
fade(node, &mut filters, Video);
|
||||
overlay(node, &mut filters, config);
|
||||
realtime_filter(node, &mut filters, config, Video);
|
||||
realtime_filter(node, &mut filters, config);
|
||||
|
||||
add_loudnorm(&mut filters, config);
|
||||
fade(node, &mut filters, Audio);
|
||||
audio_volume(&mut filters, config);
|
||||
realtime_filter(node, &mut filters, config, Audio);
|
||||
|
||||
custom(&config.processing.custom_filter, &mut filters);
|
||||
custom(&node.custom_filter, &mut filters);
|
||||
|
@ -1,26 +0,0 @@
|
||||
use crate::utils::PlayoutConfig;
|
||||
|
||||
/// Overlay Filter
|
||||
///
|
||||
/// When a logo is set, we create here the filter for the server.
|
||||
pub fn filter_node(config: &PlayoutConfig) -> String {
|
||||
let mut fps = config.processing.fps;
|
||||
let mut fps_filter = String::new();
|
||||
|
||||
if !config.processing.add_logo {
|
||||
return String::new();
|
||||
}
|
||||
|
||||
if let Some(f) = config.processing.logo_fps {
|
||||
fps = f;
|
||||
};
|
||||
|
||||
if config.processing.fps != fps {
|
||||
fps_filter = format!(",fps={}", config.processing.fps);
|
||||
}
|
||||
|
||||
format!(
|
||||
"null[v];movie={}:loop=0,setpts=N/({fps}*TB),format=rgba,colorchannelmixer=aa={}{fps_filter}[l];[v][l]{}:shortest=1",
|
||||
config.processing.logo, config.processing.logo_opacity, config.processing.logo_filter
|
||||
)
|
||||
}
|
@ -8,7 +8,7 @@ use std::{
|
||||
use serde::{Deserialize, Serialize};
|
||||
use shlex::split;
|
||||
|
||||
use crate::utils::{fps_calc, free_tcp_socket, home_dir, time_to_sec, MediaProbe};
|
||||
use crate::utils::{free_tcp_socket, home_dir, time_to_sec};
|
||||
use crate::vec_strings;
|
||||
|
||||
pub const DUMMY_LEN: f64 = 60.0;
|
||||
@ -96,10 +96,6 @@ pub struct Processing {
|
||||
pub fps: f64,
|
||||
pub add_logo: bool,
|
||||
pub logo: String,
|
||||
|
||||
#[serde(skip_serializing, skip_deserializing)]
|
||||
pub logo_fps: Option<f64>,
|
||||
|
||||
pub logo_scale: String,
|
||||
pub logo_opacity: f32,
|
||||
pub logo_filter: String,
|
||||
@ -234,17 +230,8 @@ impl PlayoutConfig {
|
||||
config.playlist.length_sec = Some(86400.0);
|
||||
}
|
||||
|
||||
config.processing.logo_fps = None;
|
||||
|
||||
if Path::new(&config.processing.logo).is_file() {
|
||||
if let Some(v_stream) = MediaProbe::new(&config.processing.logo)
|
||||
.video_streams
|
||||
.get(0)
|
||||
{
|
||||
let fps = fps_calc(&v_stream.r_frame_rate, config.processing.fps);
|
||||
|
||||
config.processing.logo_fps = Some(fps);
|
||||
};
|
||||
if config.processing.add_logo && !Path::new(&config.processing.logo).is_file() {
|
||||
config.processing.add_logo = false;
|
||||
}
|
||||
|
||||
// We set the decoder settings here, so we only define them ones.
|
||||
|
@ -495,7 +495,7 @@ pub fn seek_and_length(node: &Media) -> Vec<String> {
|
||||
let mut source_cmd = vec![];
|
||||
let mut cut_audio = false;
|
||||
|
||||
if node.seek > 0.0 {
|
||||
if node.seek > 0.5 {
|
||||
source_cmd.append(&mut vec_strings!["-ss", node.seek])
|
||||
}
|
||||
|
||||
@ -504,7 +504,7 @@ pub fn seek_and_length(node: &Media) -> Vec<String> {
|
||||
if Path::new(&node.audio).is_file() {
|
||||
let audio_probe = MediaProbe::new(&node.audio);
|
||||
|
||||
if node.seek > 0.0 {
|
||||
if node.seek > 0.5 {
|
||||
source_cmd.append(&mut vec_strings!["-ss", node.seek])
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user