Generating a HLS playlist through ffmpeg

I might be able to streamline the requests to cut down on the endpoints.
This also will likely take some time if the file is large and could time
out, that may be a concern for another day.
This commit is contained in:
Cameron Cordes
2020-07-13 22:39:00 -04:00
parent 78c066b7be
commit c39bf970be
2 changed files with 70 additions and 2 deletions

24
src/video.rs Normal file
View File

@@ -0,0 +1,24 @@
use std::process::Command;
// ffmpeg -i test.mp4 -c:v h264 -flags +cgop -g 30 -hls_time 3 out.m3u8
pub fn create_playlist(video_path: &str, playlist_file: &str) {
let result = Command::new("ffmpeg")
.arg("-i")
.arg(video_path)
.arg("-c:v")
.arg("h264")
.arg("-flags")
.arg("+cgop")
.arg("-g")
.arg("30")
.arg("-hls_time")
.arg("5")
.arg(playlist_file)
.output()
.expect("Expected this to work..");
println!("{:?}", result);
println!("Status: {}", String::from_utf8(result.stdout).unwrap())
}