work on looping clips
This commit is contained in:
parent
be5e34bb9a
commit
ec5ef03908
@ -236,7 +236,7 @@ impl CurrentProgram {
|
||||
.current_list
|
||||
.lock()
|
||||
.unwrap()
|
||||
.iter_mut()
|
||||
.iter()
|
||||
.enumerate()
|
||||
{
|
||||
if item.begin.unwrap() + item.out - item.seek > time_sec {
|
||||
@ -260,7 +260,7 @@ impl CurrentProgram {
|
||||
.player_control
|
||||
.current_index
|
||||
.fetch_add(1, Ordering::SeqCst);
|
||||
let nodes = self.player_control.current_list.lock().unwrap();
|
||||
let mut nodes = self.player_control.current_list.lock().unwrap();
|
||||
let last_index = nodes.len() - 1;
|
||||
|
||||
// de-instance node to preserve original values in list
|
||||
@ -271,6 +271,32 @@ impl CurrentProgram {
|
||||
node_clone.seek += time_sec
|
||||
- (node_clone.begin.unwrap() - *self.playout_stat.time_shift.lock().unwrap());
|
||||
|
||||
if node_clone.out > node_clone.duration {
|
||||
let mut node_duplicate = node_clone.clone();
|
||||
node_duplicate.begin =
|
||||
Some(node_duplicate.begin.unwrap_or_default() + node_duplicate.duration);
|
||||
node_duplicate.seek = 0.0;
|
||||
node_duplicate.out -= node_duplicate.duration;
|
||||
|
||||
println!(
|
||||
"seek: {}; out: {}; duration: {}; begin: {:?}",
|
||||
node_duplicate.seek,
|
||||
node_duplicate.out,
|
||||
node_duplicate.duration,
|
||||
node_duplicate.begin
|
||||
);
|
||||
|
||||
nodes.insert(index + 1, node_duplicate);
|
||||
|
||||
for (i, item) in nodes.iter_mut().enumerate() {
|
||||
item.index = Some(i);
|
||||
}
|
||||
|
||||
node_clone.out = node_clone.duration;
|
||||
}
|
||||
|
||||
println!("{:?}", nodes);
|
||||
|
||||
// Important! When no manual drop is happen here, lock is still active in handle_list_init
|
||||
drop(nodes);
|
||||
|
||||
@ -394,6 +420,7 @@ impl Iterator for CurrentProgram {
|
||||
let node_list = self.player_control.current_list.lock().unwrap();
|
||||
let node = node_list[index].clone();
|
||||
let last_index = node_list.len() - 1;
|
||||
|
||||
drop(node_list);
|
||||
|
||||
if index == last_index {
|
||||
|
@ -529,6 +529,7 @@ pub fn loop_filler(node: &Media) -> Vec<String> {
|
||||
|
||||
/// Set clip seek in and length value.
|
||||
pub fn seek_and_length(node: &mut Media) -> Vec<String> {
|
||||
let loop_count = (node.out / node.duration).ceil() as i32;
|
||||
let mut source_cmd = vec![];
|
||||
let mut cut_audio = false;
|
||||
let mut loop_audio = false;
|
||||
@ -541,9 +542,15 @@ pub fn seek_and_length(node: &mut Media) -> Vec<String> {
|
||||
source_cmd.append(&mut vec_strings!["-ss", node.seek])
|
||||
}
|
||||
|
||||
if loop_count > 1 {
|
||||
info!("Loop <b><magenta>{}</></b> <yellow>{loop_count}</> times, total duration: <yellow>{:.2}</>", node.source, node.out);
|
||||
|
||||
source_cmd.append(&mut vec_strings!["-stream_loop", loop_count]);
|
||||
}
|
||||
|
||||
source_cmd.append(&mut vec_strings!["-i", node.source.clone()]);
|
||||
|
||||
if node.duration > node.out || remote_source {
|
||||
if node.duration > node.out || remote_source || loop_count > 1 {
|
||||
source_cmd.append(&mut vec_strings!["-t", node.out - node.seek]);
|
||||
}
|
||||
|
||||
@ -552,9 +559,9 @@ pub fn seek_and_length(node: &mut Media) -> Vec<String> {
|
||||
source_cmd.append(&mut vec_strings!["-ss", node.seek]);
|
||||
}
|
||||
|
||||
if node.duration_audio > node.duration {
|
||||
if node.duration_audio > node.out {
|
||||
cut_audio = true;
|
||||
} else if node.duration_audio < node.duration {
|
||||
} else if node.duration_audio < node.out {
|
||||
source_cmd.append(&mut vec_strings!["-stream_loop", -1]);
|
||||
loop_audio = true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user