improve live sources, fix #473
Live sources are potentially unstable and are therefore not officially supported. Use at your own risk.
This commit is contained in:
parent
0c22b5c677
commit
9912405e4e
@ -89,7 +89,7 @@ async fn main() -> std::io::Result<()> {
|
|||||||
let port = ip_port[1].parse::<u16>().unwrap();
|
let port = ip_port[1].parse::<u16>().unwrap();
|
||||||
let engine_process = web::Data::new(ProcessControl::new());
|
let engine_process = web::Data::new(ProcessControl::new());
|
||||||
|
|
||||||
info!("running ffplayout API, listen on {conn}");
|
info!("running ffplayout API, listen on http://{conn}");
|
||||||
|
|
||||||
// no 'allow origin' here, give it to the reverse proxy
|
// no 'allow origin' here, give it to the reverse proxy
|
||||||
HttpServer::new(move || {
|
HttpServer::new(move || {
|
||||||
|
@ -618,7 +618,7 @@ pub fn gen_source(
|
|||||||
{
|
{
|
||||||
node.cmd = Some(loop_image(&node));
|
node.cmd = Some(loop_image(&node));
|
||||||
} else {
|
} else {
|
||||||
node.cmd = Some(seek_and_length(&node));
|
node.cmd = Some(seek_and_length(&mut node));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
trace!(
|
trace!(
|
||||||
|
@ -58,7 +58,7 @@ fn check_media(
|
|||||||
{
|
{
|
||||||
node.cmd = Some(loop_image(&node));
|
node.cmd = Some(loop_image(&node));
|
||||||
} else {
|
} else {
|
||||||
node.cmd = Some(seek_and_length(&node));
|
node.cmd = Some(seek_and_length(&mut node));
|
||||||
}
|
}
|
||||||
|
|
||||||
node.add_filter(&config, &None);
|
node.add_filter(&config, &None);
|
||||||
|
@ -273,7 +273,8 @@ impl MediaProbe {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
if !Path::new(input).is_file() {
|
println!("{e}");
|
||||||
|
if !Path::new(input).is_file() && !is_remote(input) {
|
||||||
Err(ProcError::Custom(format!("File '{input}' not exist!")))
|
Err(ProcError::Custom(format!("File '{input}' not exist!")))
|
||||||
} else {
|
} else {
|
||||||
Err(ProcError::Ffprobe(e))
|
Err(ProcError::Ffprobe(e))
|
||||||
@ -521,18 +522,22 @@ pub fn loop_filler(node: &Media) -> Vec<String> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Set clip seek in and length value.
|
/// Set clip seek in and length value.
|
||||||
pub fn seek_and_length(node: &Media) -> Vec<String> {
|
pub fn seek_and_length(node: &mut Media) -> Vec<String> {
|
||||||
let mut source_cmd = vec![];
|
let mut source_cmd = vec![];
|
||||||
let mut cut_audio = false;
|
let mut cut_audio = false;
|
||||||
let mut loop_audio = false;
|
let mut loop_audio = false;
|
||||||
|
let remote_source = is_remote(&node.source);
|
||||||
|
|
||||||
if node.seek > 0.5 {
|
if remote_source && node.probe.clone().and_then(|f| f.format.duration).is_none() {
|
||||||
|
node.out -= node.seek;
|
||||||
|
node.seek = 0.0;
|
||||||
|
} else if node.seek > 0.5 {
|
||||||
source_cmd.append(&mut vec_strings!["-ss", node.seek])
|
source_cmd.append(&mut vec_strings!["-ss", node.seek])
|
||||||
}
|
}
|
||||||
|
|
||||||
source_cmd.append(&mut vec_strings!["-i", node.source.clone()]);
|
source_cmd.append(&mut vec_strings!["-i", node.source.clone()]);
|
||||||
|
|
||||||
if node.duration > node.out {
|
if node.duration > node.out || remote_source {
|
||||||
source_cmd.append(&mut vec_strings!["-t", node.out - node.seek]);
|
source_cmd.append(&mut vec_strings!["-t", node.out - node.seek]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -550,7 +555,7 @@ pub fn seek_and_length(node: &Media) -> Vec<String> {
|
|||||||
|
|
||||||
source_cmd.append(&mut vec_strings!["-i", node.audio.clone()]);
|
source_cmd.append(&mut vec_strings!["-i", node.audio.clone()]);
|
||||||
|
|
||||||
if cut_audio || loop_audio {
|
if cut_audio || loop_audio || remote_source {
|
||||||
source_cmd.append(&mut vec_strings!["-t", node.out - node.seek]);
|
source_cmd.append(&mut vec_strings!["-t", node.out - node.seek]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -601,7 +606,9 @@ pub fn gen_dummy(config: &PlayoutConfig, duration: f64) -> (String, Vec<String>)
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
pub fn is_remote(path: &str) -> bool {
|
pub fn is_remote(path: &str) -> bool {
|
||||||
Regex::new(r"^https?://.*").unwrap().is_match(path)
|
Regex::new(r"^(https?|rtmps?|rtp|rtsp|udp|tcp|srt)://.*")
|
||||||
|
.unwrap()
|
||||||
|
.is_match(&path.to_lowercase())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check if file can include or has to exclude.
|
/// Check if file can include or has to exclude.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user