work on case when playlist is to long
This commit is contained in:
parent
330973f19e
commit
0253b9d605
@ -77,6 +77,7 @@ pub struct Playlist {
|
|||||||
pub day_start: String,
|
pub day_start: String,
|
||||||
pub start_sec: Option<f64>,
|
pub start_sec: Option<f64>,
|
||||||
pub length: String,
|
pub length: String,
|
||||||
|
pub length_sec: Option<f64>,
|
||||||
pub infinit: bool,
|
pub infinit: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,6 +134,12 @@ pub fn get_config() -> Config {
|
|||||||
let bitrate = config.processing.width * config.processing.height / 10;
|
let bitrate = config.processing.width * config.processing.height / 10;
|
||||||
config.playlist.start_sec = Some(time_to_sec(&config.playlist.day_start));
|
config.playlist.start_sec = Some(time_to_sec(&config.playlist.day_start));
|
||||||
|
|
||||||
|
if config.playlist.length.contains(":") {
|
||||||
|
config.playlist.length_sec = Some(time_to_sec(&config.playlist.length));
|
||||||
|
} else {
|
||||||
|
config.playlist.length_sec = Some(86400.0);
|
||||||
|
}
|
||||||
|
|
||||||
let settings = vec![
|
let settings = vec![
|
||||||
"-pix_fmt",
|
"-pix_fmt",
|
||||||
"yuv420p",
|
"yuv420p",
|
||||||
@ -191,6 +198,12 @@ pub fn get_config() -> Config {
|
|||||||
|
|
||||||
if args.length.is_some() {
|
if args.length.is_some() {
|
||||||
config.playlist.length = args.length.clone().unwrap();
|
config.playlist.length = args.length.clone().unwrap();
|
||||||
|
|
||||||
|
if config.playlist.length.contains(":") {
|
||||||
|
config.playlist.length_sec = Some(time_to_sec(&config.playlist.length));
|
||||||
|
} else {
|
||||||
|
config.playlist.length_sec = Some(86400.0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if args.infinit {
|
if args.infinit {
|
||||||
|
@ -4,7 +4,7 @@ use simplelog::*;
|
|||||||
|
|
||||||
use crate::utils::{
|
use crate::utils::{
|
||||||
check_sync, gen_dummy, get_delta, get_sec, json_reader::read_json, modified_time,
|
check_sync, gen_dummy, get_delta, get_sec, json_reader::read_json, modified_time,
|
||||||
seek_and_length, time_to_sec, Config, Media, DUMMY_LEN,
|
seek_and_length, Config, Media, DUMMY_LEN,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@ -92,16 +92,13 @@ impl CurrentProgram {
|
|||||||
|
|
||||||
let next_start = self.current_node.begin.unwrap() - start_sec + out + delta;
|
let next_start = self.current_node.begin.unwrap() - start_sec + out + delta;
|
||||||
|
|
||||||
if self.config.playlist.length.contains(":") {
|
if next_start >= self.config.playlist.length_sec.unwrap() {
|
||||||
let playlist_length = time_to_sec(&self.config.playlist.length);
|
|
||||||
if next_start >= playlist_length {
|
|
||||||
let json = read_json(&self.config, false, next_start);
|
let json = read_json(&self.config, false, next_start);
|
||||||
|
|
||||||
self.json_mod = json.modified;
|
self.json_mod = json.modified;
|
||||||
self.nodes = json.program;
|
self.nodes = json.program;
|
||||||
self.index = 0;
|
self.index = 0;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// println!("{}", next_start);
|
// println!("{}", next_start);
|
||||||
}
|
}
|
||||||
@ -139,15 +136,9 @@ impl CurrentProgram {
|
|||||||
|
|
||||||
fn get_init_clip(&mut self) {
|
fn get_init_clip(&mut self) {
|
||||||
let mut time_sec = get_sec();
|
let mut time_sec = get_sec();
|
||||||
let length = self.config.playlist.length.clone();
|
|
||||||
let mut length_sec: f64 = 86400.0;
|
|
||||||
|
|
||||||
if length.contains(":") {
|
|
||||||
length_sec = time_to_sec(&length);
|
|
||||||
}
|
|
||||||
|
|
||||||
if time_sec < self.start_sec {
|
if time_sec < self.start_sec {
|
||||||
time_sec += length_sec
|
time_sec += self.config.playlist.length_sec.unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut start_sec = self.start_sec.clone();
|
let mut start_sec = self.start_sec.clone();
|
||||||
@ -157,12 +148,7 @@ impl CurrentProgram {
|
|||||||
self.init = false;
|
self.init = false;
|
||||||
self.index = i + 1;
|
self.index = i + 1;
|
||||||
item.seek = time_sec - start_sec;
|
item.seek = time_sec - start_sec;
|
||||||
item.cmd = Some(seek_and_length(
|
|
||||||
item.source.clone(),
|
|
||||||
item.seek,
|
|
||||||
item.out,
|
|
||||||
item.duration,
|
|
||||||
));
|
|
||||||
self.current_node = handle_list_init(item.clone(), &self.config);
|
self.current_node = handle_list_init(item.clone(), &self.config);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -205,7 +191,10 @@ impl Iterator for CurrentProgram {
|
|||||||
|
|
||||||
return Some(self.current_node.clone());
|
return Some(self.current_node.clone());
|
||||||
}
|
}
|
||||||
if self.index < self.nodes.len() {
|
if self.index < self.nodes.len()
|
||||||
|
&& self.current_node.begin.unwrap() + self.current_node.out - self.current_node.seek
|
||||||
|
<= self.config.playlist.length_sec.unwrap() + self.config.playlist.start_sec.unwrap()
|
||||||
|
{
|
||||||
self.check_update();
|
self.check_update();
|
||||||
|
|
||||||
self.get_current_node(self.index);
|
self.get_current_node(self.index);
|
||||||
@ -335,7 +324,14 @@ fn handle_list_init(mut node: Media, config: &Config) -> Media {
|
|||||||
}
|
}
|
||||||
|
|
||||||
node.out = out;
|
node.out = out;
|
||||||
let new_node = gen_source(node, &config);
|
|
||||||
|
let mut new_node = gen_source(node, &config);
|
||||||
|
new_node.cmd = Some(seek_and_length(
|
||||||
|
new_node.source.clone(),
|
||||||
|
new_node.seek,
|
||||||
|
new_node.out,
|
||||||
|
new_node.duration,
|
||||||
|
));
|
||||||
|
|
||||||
new_node
|
new_node
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user