Improve video streaming speed
All checks were successful
Core Repos/ImageApi/pipeline/head This commit looks good
All checks were successful
Core Repos/ImageApi/pipeline/head This commit looks good
Instead of waiting for an entire video to stream, we spawn a child ffmpeg process to start generating the HLS playlist, and once it creates the first part of the playlist we return the response so the client can start streaming almost immediately. HTTP Live streaming can handle playlist updates after the initial playlist is created, although I don't think the user can skip to the end and skip streaming parts of the video.
This commit is contained in:
13
src/video.rs
13
src/video.rs
@@ -26,11 +26,16 @@ pub fn create_playlist(video_path: &str, playlist_file: &str) {
|
||||
.arg("-vf")
|
||||
.arg("scale=1080:-2,setsar=1:1")
|
||||
.arg(playlist_file)
|
||||
.output()
|
||||
.expect("Expected this to work..");
|
||||
.spawn();
|
||||
|
||||
println!("{:?}", result);
|
||||
println!("Status: {}", String::from_utf8(result.stdout).unwrap())
|
||||
let start_time = std::time::Instant::now();
|
||||
loop {
|
||||
std::thread::sleep(std::time::Duration::from_secs(1));
|
||||
|
||||
if Path::new(playlist_file).exists() || std::time::Instant::now() - start_time > std::time::Duration::from_secs(5) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn generate_video_thumbnail(path: &Path, destination: &Path) {
|
||||
|
||||
Reference in New Issue
Block a user