Skip to content

Commit

Permalink
option to full override filters
Browse files Browse the repository at this point in the history
  • Loading branch information
jb-alvarado committed Feb 4, 2025
1 parent 13f5b40 commit 0f583ae
Show file tree
Hide file tree
Showing 16 changed files with 168 additions and 105 deletions.
171 changes: 96 additions & 75 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion engine/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ async-walkdir = "2"
chrono = { version = "0.4", default-features = false, features = ["clock", "std", "serde"] }
chrono-tz = { version = "0.10", features = ["serde"] }
clap = { version = "4.3", features = ["derive", "env"] }
derive_more = { version = "1", features = ["display"] }
derive_more = { version = "2", features = ["display"] }
faccess = "0.2"
flexi_logger = { version = "0.29", features = ["async", "colors", "kv"] }
futures-util = { version = "0.3", default-features = false, features = ["std"] }
Expand Down
13 changes: 2 additions & 11 deletions engine/src/db/handles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,6 @@ pub async fn db_migrate(conn: &Pool<Sqlite>) -> Result<(), ProcessError> {
.bind(shared)
.execute(conn)
.await?;

insert_advanced_configuration(
conn,
1,
AdvancedConfig {
name: Some("None".to_string()),
..Default::default()
},
)
.await?;
}

Ok(())
Expand Down Expand Up @@ -266,7 +256,7 @@ pub async fn update_configuration(
id: i32,
config: PlayoutConfig,
) -> Result<SqliteQueryResult, ProcessError> {
const QUERY: &str = "UPDATE configurations SET general_stop_threshold = $2, mail_subject = $3, mail_recipient = $4, mail_level = $5, mail_interval = $6, logging_ffmpeg_level = $7, logging_ingest_level = $8, logging_detect_silence = $9, logging_ignore = $10, processing_mode = $11, processing_audio_only = $12, processing_copy_audio = $13, processing_copy_video = $14, processing_width = $15, processing_height = $16, processing_aspect = $17, processing_fps = $18, processing_add_logo = $19, processing_logo = $20, processing_logo_scale = $21, processing_logo_opacity = $22, processing_logo_position = $23, processing_audio_tracks = $24, processing_audio_track_index = $25, processing_audio_channels = $26, processing_volume = $27, processing_filter = $28, processing_vtt_enable = $29, processing_vtt_dummy = $30, ingest_enable = $31, ingest_param = $32, ingest_filter = $33, playlist_day_start = $34, playlist_length = $35, playlist_infinit = $36, storage_filler = $37, storage_extensions = $38, storage_shuffle = $39, text_add = $40, text_from_filename = $41, text_font = $42, text_style = $43, text_regex = $44, task_enable = $45, task_path = $46, output_mode = $47, output_param = $48 WHERE id = $1";
const QUERY: &str = "UPDATE configurations SET general_stop_threshold = $2, mail_subject = $3, mail_recipient = $4, mail_level = $5, mail_interval = $6, logging_ffmpeg_level = $7, logging_ingest_level = $8, logging_detect_silence = $9, logging_ignore = $10, processing_mode = $11, processing_audio_only = $12, processing_copy_audio = $13, processing_copy_video = $14, processing_width = $15, processing_height = $16, processing_aspect = $17, processing_fps = $18, processing_add_logo = $19, processing_logo = $20, processing_logo_scale = $21, processing_logo_opacity = $22, processing_logo_position = $23, processing_audio_tracks = $24, processing_audio_track_index = $25, processing_audio_channels = $26, processing_volume = $27, processing_filter = $28, processing_override_filter = $29, processing_vtt_enable = $30, processing_vtt_dummy = $31, ingest_enable = $32, ingest_param = $33, ingest_filter = $34, playlist_day_start = $35, playlist_length = $36, playlist_infinit = $37, storage_filler = $38, storage_extensions = $39, storage_shuffle = $40, text_add = $41, text_from_filename = $42, text_font = $43, text_style = $44, text_regex = $45, task_enable = $46, task_path = $47, output_mode = $48, output_param = $49 WHERE id = $1";

let result = sqlx::query(QUERY)
.bind(id)
Expand Down Expand Up @@ -297,6 +287,7 @@ pub async fn update_configuration(
.bind(config.processing.audio_channels)
.bind(config.processing.volume)
.bind(config.processing.custom_filter)
.bind(config.processing.override_filter)
.bind(config.processing.vtt_enable)
.bind(config.processing.vtt_dummy)
.bind(config.ingest.enable)
Expand Down
3 changes: 3 additions & 0 deletions engine/src/db/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,8 @@ pub struct Configuration {
#[serde(default)]
pub processing_filter: String,
#[serde(default)]
pub processing_override_filter: bool,
#[serde(default)]
pub processing_vtt_enable: bool,
#[serde(default)]
pub processing_vtt_dummy: Option<String>,
Expand Down Expand Up @@ -380,6 +382,7 @@ impl Configuration {
processing_audio_channels: config.processing.audio_channels,
processing_volume: config.processing.volume,
processing_filter: config.processing.custom_filter,
processing_override_filter: config.processing.override_filter,
processing_vtt_enable: config.processing.vtt_enable,
processing_vtt_dummy: config.processing.vtt_dummy,
ingest_enable: config.ingest.enable,
Expand Down
16 changes: 16 additions & 0 deletions engine/src/player/filter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use std::{fmt, path::Path, sync::Arc};

use log::*;
use regex::Regex;
use shlex::split;
use tokio::sync::Mutex;

mod custom;
Expand Down Expand Up @@ -233,6 +234,10 @@ impl Filters {
}

pub fn map(&mut self) -> Vec<String> {
if !self.output_chain.is_empty() && self.config.processing.override_filter {
return vec![];
}

let mut o_map = self.output_map.clone();

if self.video_last == -1 && !self.config.processing.audio_only {
Expand Down Expand Up @@ -664,6 +669,17 @@ pub async fn filter_chains(
) -> Filters {
let mut filters = Filters::new(config.clone(), 0);

if config.processing.override_filter {
//override hole filtering
if node.unit == Ingest && !config.ingest.custom_filter.is_empty() {
filters.output_chain = split(&config.ingest.custom_filter).unwrap_or_default();
} else {
filters.output_chain = split(&config.processing.custom_filter).unwrap_or_default();
}

return filters;
}

if node.source.contains("color=c=") {
filters.audio_position = 1;
}
Expand Down
5 changes: 1 addition & 4 deletions engine/src/player/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,7 @@ pub fn prepare_output_cmd(
if filter.video_out_link.len() > count
&& !output_params.contains(&"-map".to_string())
{
new_params.append(&mut vec_strings![
"-map",
filter.video_out_link[count].clone()
]);
new_params.append(&mut vec_strings!["-map", filter.video_out_link[count]]);

for i in 0..config.processing.audio_tracks {
new_params.append(&mut vec_strings!["-map", format!("0:a:{i}")]);
Expand Down
27 changes: 21 additions & 6 deletions engine/src/utils/args_parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ pub struct Args {
#[clap(long, env, help_heading = Some("Initial Setup"), help = "SMTP password for system mails")]
pub smtp_password: Option<String>,

#[clap(long, env, help_heading = Some("Initial Setup"), help = "Use TLS for system SMTP")]
pub smtp_starttls: bool,
#[clap(long, env, help_heading = Some("Initial Setup"), help = "Use TLS for system SMTP", value_name = "TRUE/FALSE")]
pub smtp_starttls: Option<String>,

#[clap(long, env, help_heading = Some("Initial Setup"), help = "SMTP port for system mail")]
pub smtp_port: Option<u16>,
Expand Down Expand Up @@ -304,12 +304,27 @@ pub async fn run_args(pool: &Pool<Sqlite>) -> Result<(), ProcessError> {
}
}

if args.smtp_starttls {
global.smtp_starttls = true;
} else {
global.smtp_starttls = Confirm::new("SMTP use TLS").with_default(false).prompt()?;
match args.smtp_starttls {
Some(val) => match val.to_lowercase().as_str() {
"true" => global.smtp_starttls = true,
"false" => global.smtp_starttls = false,
_ => {
return Err(ProcessError::Input(
"--smtp-starttls accept true or false".to_string(),
))
}
},
None => {
global.smtp_starttls = Confirm::new("SMTP use TLS").with_default(false).prompt()?;
}
}

// if args.smtp_starttls {
// global.smtp_starttls = true;
// } else {
// global.smtp_starttls = Confirm::new("SMTP use TLS").with_default(false).prompt()?;
// }

if let Some(port) = args.smtp_port {
global.smtp_port = port;
} else {
Expand Down
4 changes: 3 additions & 1 deletion engine/src/utils/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ pub struct Processing {
pub audio_channels: u8,
pub volume: f64,
pub custom_filter: String,
pub override_filter: bool,
#[serde(default)]
pub vtt_enable: bool,
#[serde(default)]
Expand Down Expand Up @@ -391,6 +392,7 @@ impl Processing {
audio_channels: config.processing_audio_channels,
volume: config.processing_volume,
custom_filter: config.processing_filter.clone(),
override_filter: config.processing_override_filter,
vtt_enable: config.processing_vtt_enable,
vtt_dummy: config.processing_vtt_dummy.clone(),
cmd: None,
Expand Down Expand Up @@ -954,7 +956,7 @@ pub async fn get_config(
config.mail.smtp_password = smtp_password;
}

if args.smtp_starttls {
if args.smtp_starttls.is_some_and(|v| &v == "true") {
config.mail.smtp_starttls = true;
}

Expand Down
17 changes: 16 additions & 1 deletion frontend/components/ConfigPlayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,21 @@
}}</span>
</div>
</label>
<label class="form-control w-full flex-row mt-0">
<input
v-model="configStore.playout.processing.override_filter"
type="checkbox"
class="checkbox checkbox-sm me-1 mt-2"
/>
<div class="label">
<span class="label-text !text-md font-bold">Override custom Filter</span>
</div>
</label>
<div v-if="configStore.playout.processing.override_filter" class="label py-0">
<span class="text-sm select-text font-bold text-orange-500">{{
t('config.processingOverrideFilter')
}}</span>
</div>
<label class="form-control w-full mt-2">
<div class="flex flex-row">
<input
Expand Down Expand Up @@ -756,7 +771,7 @@ const extensions = computed({
set(value: string) {
configStore.playout.storage.extensions = value.replaceAll(' ', '').split(/,|;/)
}
},
})
const formatIgnoreLines = computed({
Expand Down
1 change: 1 addition & 0 deletions frontend/i18n/locales/de-DE.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ export default {
processingAudioIndex: 'Welche Audiospur verwendet werden soll, -1 für alle.',
processingAudioChannels: 'Stelle die Anzahl der Audiokanäle ein, wenn das Audio mehr Kanäle als Stereo hat.',
processingCustomFilter: 'Füge benutzerdefinierte Filter zur Verarbeitung hinzu. Die Filterausgaben müssen mit [c_v_out] für Video-Filter und [c_a_out] für Audio-Filter enden.',
processingOverrideFilter: 'Achtung: Diese Option überschreibt alle Standardfilter, d.h. es findet keine automatische Formatkorrektur mehr statt, der Befehl muss wie folgt aufgebaut sein: -filter_complex [0:v]fps=25,scale=1280:-1[vout];[0:a:0]volume=0.5[aout] -map [vout] -map [aout]',
processingVTTEnable: 'VTT kann nur im HLS-Modus verwendet werden und nur, wenn *.vtt-Dateien mit demselben Namen wie die Videodatei vorhanden sind.',
processingVTTDummy: 'Ein Platzhalter wird benötigt, wenn keine vtt-Datei vorhanden ist.',
ingestHelp: `Starte einen Server für einen Ingest-Stream. Dieser Stream wird den normalen Stream überschreiben, bis er beendet ist. Es gibt nur einen sehr einfachen Authentifizierungsmechanismus, der überprüft, ob der Streamname korrekt ist.`,
Expand Down
1 change: 1 addition & 0 deletions frontend/i18n/locales/en-US.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ export default {
processingAudioIndex: 'Which audio line to use, -1 for all.',
processingAudioChannels: 'Set the audio channel count, if audio has more channels than stereo.',
processingCustomFilter: 'Add custom filters to the processing. The filter outputs must end with [c_v_out] for video filters and [c_a_out] for audio filters.',
processingOverrideFilter: 'Attention: This option overwrites all standard filters, i.e. automatic format correction no longer takes place, the command must be structured as follows: -filter_complex [0:v]fps=25,scale=1280:-1[vout];[0:a:0]volume=0.5[aout] -map [vout] -map [aout]',
processingVTTEnable: 'VTT can only be used in HLS mode and only if there are *.vtt files with the same name as the video file.',
processingVTTDummy: 'A placeholder is needed if there is no vtt file.',
ingestHelp: `Run a server for an ingest stream. This stream will override the normal streaming until it is finished. There is only a very simple authentication mechanism, which checks if the stream name is correct.`,
Expand Down
1 change: 1 addition & 0 deletions frontend/i18n/locales/pt-BR.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ export default {
processingAudioIndex: 'Qual linha de áudio usar, -1 para todas.',
processingAudioChannels: 'Defina a contagem de canais de áudio, se o áudio tiver mais canais do que estéreo.',
processingCustomFilter: 'Adicione filtros personalizados ao processamento. As saídas de filtro devem terminar com [c_v_out] para filtros de vídeo e [c_a_out] para filtros de áudio.',
processingOverrideFilter: 'Attention: This option overwrites all standard filters, i.e. automatic format correction no longer takes place, the command must be structured as follows: -filter_complex [0:v]fps=25,scale=1280:-1[vout];[0:a:0]volume=0.5[aout] -map [vout] -map [aout]',
processingVTTEnable: 'VTT só pode ser usado no modo HLS e apenas se houver arquivos *.vtt com o mesmo nome do arquivo de vídeo.',
processingVTTDummy: 'Um espaço reservado é necessário se não houver arquivo vtt.',
ingestHelp: `Execute um servidor para um fluxo de ingestão. Este fluxo substituirá o streaming normal até que termine. Há apenas um mecanismo de autenticação simples que verifica se o nome do fluxo está correto.`,
Expand Down
1 change: 1 addition & 0 deletions frontend/i18n/locales/ru-RU.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ export default {
processingAudioIndex: 'Which audio line to use, -1 for all.',
processingAudioChannels: 'Set the audio channel count, if audio has more channels than stereo.',
processingCustomFilter: 'Add custom filters to the processing. The filter outputs must end with [c_v_out] for video filters and [c_a_out] for audio filters.',
processingOverrideFilter: 'Attention: This option overwrites all standard filters, i.e. automatic format correction no longer takes place, the command must be structured as follows: -filter_complex [0:v]fps=25,scale=1280:-1[vout];[0:a:0]volume=0.5[aout] -map [vout] -map [aout]',
processingVTTEnable: 'VTT can only be used in HLS mode and only if there are *.vtt files with the same name as the video file.',
processingVTTDummy: 'A placeholder is needed if there is no vtt file.',
ingestHelp: `Run a server for an ingest stream. This stream will override the normal streaming until it is finished. There is only a very simple authentication mechanism, which checks if the stream name is correct.`,
Expand Down
2 changes: 1 addition & 1 deletion frontend/types/advanced_config.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ export type DecoderConfig = { input_param: string, output_param: string, };

export type EncoderConfig = { input_param: string, };

export type FilterConfig = { deinterlace: string, pad_scale_w: string, pad_scale_h: string, pad_video: string, fps: string, scale: string, set_dar: string, fade_in: string, fade_out: string, logo: string, overlay_logo_scale: string, overlay_logo_fade_in: string, overlay_logo_fade_out: string, overlay_logo: string, tpad: string, drawtext_from_file: string, drawtext_from_zmq: string, aevalsrc: string, afade_in: string, afade_out: string, apad: string, volume: string, split: string, };
export type FilterConfig = { deinterlace: string, pad_video: string, fps: string, scale: string, set_dar: string, fade_in: string, fade_out: string, logo: string, overlay_logo_scale: string, overlay_logo_fade_in: string, overlay_logo_fade_out: string, overlay_logo: string, tpad: string, drawtext_from_file: string, drawtext_from_zmq: string, aevalsrc: string, afade_in: string, afade_out: string, apad: string, volume: string, split: string, };

export type IngestConfig = { input_param: string, };
2 changes: 1 addition & 1 deletion frontend/types/playout_config.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export type PlayoutConfig = { general: General, mail: Mail, logging: Logging, pr

export type ProcessMode = "folder" | "playlist";

export type Processing = { mode: ProcessMode, audio_only: boolean, copy_audio: boolean, copy_video: boolean, width: bigint, height: bigint, aspect: number, fps: number, add_logo: boolean, logo: string, logo_scale: string, logo_opacity: number, logo_position: string, audio_tracks: number, audio_track_index: number, audio_channels: number, volume: number, custom_filter: string, vtt_enable: boolean, vtt_dummy: string | null, };
export type Processing = { mode: ProcessMode, audio_only: boolean, copy_audio: boolean, copy_video: boolean, width: bigint, height: bigint, aspect: number, fps: number, add_logo: boolean, logo: string, logo_scale: string, logo_opacity: number, logo_position: string, audio_tracks: number, audio_track_index: number, audio_channels: number, volume: number, custom_filter: string, override_filter: boolean, vtt_enable: boolean, vtt_dummy: string | null, };

export type Storage = { filler: string, extensions: Array<string>, shuffle: boolean, shared_storage: boolean, };

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
ALTER TABLE configurations ADD processing_override_filter INTEGER NOT NULL DEFAULT 0;
ALTER TABLE channels ADD advanced_id INTEGER REFERENCES advanced_configurations (id) ON UPDATE CASCADE ON DELETE SET DEFAULT;

ALTER TABLE advanced_configurations
Expand All @@ -8,9 +9,7 @@ DROP filter_pad_scale_h;

ALTER TABLE advanced_configurations ADD name TEXT;

INSERT INTO
advanced_configurations DEFAULT
VALUES;
UPDATE advanced_configurations SET name = 'None';

INSERT INTO
advanced_configurations (
Expand All @@ -32,7 +31,7 @@ VALUES
'-thread_queue_size 1024 -hwaccel_device 0 -hwaccel cuvid -hwaccel_output_format cuda',
'yadif_cuda=0:-1:0',
'scale_cuda={}:{}:format=yuv420p',
'scale_cuda={}',
'null',
'overlay_cuda={}:shortest=1',
'Nvidia'
);
Expand Down

0 comments on commit 0f583ae

Please sign in to comment.