use image extension

This commit is contained in:
jb-alvarado 2022-07-30 23:04:32 +02:00
parent 77b2feef95
commit c41cb4396f
4 changed files with 26 additions and 42 deletions

View File

@ -13,7 +13,7 @@ use simplelog::*;
use ffplayout_lib::utils::{ use ffplayout_lib::utils::{
check_sync, gen_dummy, get_delta, get_sec, is_close, is_remote, json_serializer::read_json, check_sync, gen_dummy, get_delta, get_sec, is_close, is_remote, json_serializer::read_json,
loop_image, loop_input, modified_time, seek_and_length, valid_source, Media, MediaProbe, loop_image, loop_input, modified_time, seek_and_length, valid_source, Media, MediaProbe,
PlayoutConfig, PlayoutStatus, DUMMY_LEN, IMAGE_CODEC_NAME, PlayoutConfig, PlayoutStatus, DUMMY_LEN, IMAGE_FORMAT,
}; };
/// Struct for current playlist. /// Struct for current playlist.
@ -448,8 +448,7 @@ fn timed_source(
} else if total_delta <= 0.0 { } else if total_delta <= 0.0 {
info!("Begin is over play time, skip: {}", node.source); info!("Begin is over play time, skip: {}", node.source);
} else if total_delta < node.duration - node.seek || last { } else if total_delta < node.duration - node.seek || last {
new_node = handle_list_end(node, total_delta); new_node = handle_list_end(config, node, total_delta, &playout_stat.chain);
new_node.add_filter(config, &playout_stat.chain);
} }
new_node new_node
@ -467,11 +466,10 @@ fn gen_source(
node.add_probe(); node.add_probe();
if node if node
.probe .source
.clone() .rsplit_once('.')
.and_then(|p| p.video_streams) .map(|(_, e)| e.to_lowercase())
.and_then(|v| v[0].codec_name.clone()) .filter(|c| IMAGE_FORMAT.contains(&c.as_str()))
.filter(|c| IMAGE_CODEC_NAME.contains(&c.as_str()))
.is_some() .is_some()
{ {
let cmd = loop_image(&node.source, duration); let cmd = loop_image(&node.source, duration);
@ -493,11 +491,12 @@ fn gen_source(
error!("Source not found: <b><magenta>{}</></b>", node.source); error!("Source not found: <b><magenta>{}</></b>", node.source);
} }
if probe if config
.clone() .storage
.video_streams .filler_clip
.and_then(|v| v[0].codec_name.clone()) .rsplit_once('.')
.filter(|c| IMAGE_CODEC_NAME.contains(&c.as_str())) .map(|(_, e)| e.to_lowercase())
.filter(|c| IMAGE_FORMAT.contains(&c.as_str()))
.is_some() .is_some()
{ {
let cmd = loop_image(&config.storage.filler_clip, duration); let cmd = loop_image(&config.storage.filler_clip, duration);
@ -550,21 +549,24 @@ fn handle_list_init(
/// when we come to last clip in playlist, /// when we come to last clip in playlist,
/// or when we reached total playtime, /// or when we reached total playtime,
/// we end up here /// we end up here
fn handle_list_end(mut node: Media, total_delta: f64) -> Media { fn handle_list_end(
config: &PlayoutConfig,
mut node: Media,
total_delta: f64,
filter_chain: &Arc<Mutex<Vec<String>>>,
) -> Media {
debug!("Playlist end"); debug!("Playlist end");
node.add_probe();
let mut out = if node.seek > 0.0 { let mut out = if node.seek > 0.0 {
node.seek + total_delta node.seek + total_delta
} else { } else {
warn!("Clip length is not in time, new duration is: <yellow>{total_delta:.2}</>");
total_delta total_delta
}; };
// prevent looping // out can't be longer then duration
if out > node.duration { if out > node.duration {
out = node.duration out = node.duration
} else {
warn!("Clip length is not in time, new duration is: <yellow>{total_delta:.2}</>")
} }
if node.duration > total_delta && total_delta > 1.0 && node.duration - node.seek >= total_delta if node.duration > total_delta && total_delta > 1.0 && node.duration - node.seek >= total_delta
@ -592,23 +594,5 @@ fn handle_list_end(mut node: Media, total_delta: f64) -> Media {
node.process = Some(true); node.process = Some(true);
if node gen_source(config, node, filter_chain)
.probe
.clone()
.and_then(|p| p.video_streams)
.and_then(|v| v[0].codec_name.clone())
.filter(|c| IMAGE_CODEC_NAME.contains(&c.as_str()))
.is_some()
{
node.cmd = Some(loop_image(&node.source, total_delta));
} else {
node.cmd = Some(seek_and_length(
node.source.clone(),
node.seek,
node.out,
node.duration,
));
}
node
} }

@ -1 +1 @@
Subproject commit d0a2fa6921172d667ce718e9362d4076fc16c23c Subproject commit c02141af54762961cf559248a3c9d42e9d317e0b

View File

@ -12,9 +12,9 @@ use crate::utils::{free_tcp_socket, time_to_sec};
use crate::vec_strings; use crate::vec_strings;
pub const DUMMY_LEN: f64 = 60.0; pub const DUMMY_LEN: f64 = 60.0;
pub const IMAGE_CODEC_NAME: [&str; 23] = [ pub const IMAGE_FORMAT: [&str; 21] = [
"bmp", "dds", "dpx", "exr", "gif", "hdr", "j2k", "jpeg2000", "jpegls", "jpegxl", "mjpeg", "bmp", "dds", "dpx", "exr", "gif", "hdr", "j2k", "jpg", "jpeg", "pcx", "pfm", "pgm", "phm",
"pcx", "pfm", "pgm", "phm", "png", "psd", "ppm", "sgi", "svg", "targa", "tiff", "webp", "png", "psd", "ppm", "sgi", "svg", "tga", "tif", "webp",
]; ];
/// Global Config /// Global Config

View File

@ -27,7 +27,7 @@ pub mod json_serializer;
mod json_validate; mod json_validate;
mod logging; mod logging;
pub use config::{self as playout_config, PlayoutConfig, DUMMY_LEN, IMAGE_CODEC_NAME}; pub use config::{self as playout_config, PlayoutConfig, DUMMY_LEN, IMAGE_FORMAT};
pub use controller::{PlayerControl, PlayoutStatus, ProcessControl, ProcessUnit::*}; pub use controller::{PlayerControl, PlayoutStatus, ProcessControl, ProcessUnit::*};
pub use generator::generate_playlist; pub use generator::generate_playlist;
pub use json_serializer::{read_json, JsonPlaylist}; pub use json_serializer::{read_json, JsonPlaylist};