Check and use correct paths for generating HLS playlist
This also should prevent generating the playlist if it already exists and uses a better ffmpeg command for transcoding the video.
This commit is contained in:
21
src/video.rs
21
src/video.rs
@@ -1,19 +1,30 @@
|
||||
use std::process::Command;
|
||||
use std::path::Path;
|
||||
|
||||
// ffmpeg -i test.mp4 -c:v h264 -flags +cgop -g 30 -hls_time 3 out.m3u8
|
||||
// ffmpeg -i "filename.mp4" -preset veryfast -c:v libx264 -f hls -hls_list_size 100 -hls_time 2 -crf 24 -vf scale=1080:-2,setsar=1:1 attempt/vid_out.m3u8
|
||||
|
||||
pub fn create_playlist(video_path: &str, playlist_file: &str) {
|
||||
if Path::new(playlist_file).exists() {
|
||||
println!("Playlist already exists: {}", playlist_file);
|
||||
return;
|
||||
}
|
||||
|
||||
let result = Command::new("ffmpeg")
|
||||
.arg("-i")
|
||||
.arg(video_path)
|
||||
.arg("-c:v")
|
||||
.arg("h264")
|
||||
.arg("-flags")
|
||||
.arg("+cgop")
|
||||
.arg("-g")
|
||||
.arg("30")
|
||||
.arg("-crf")
|
||||
.arg("23")
|
||||
.arg("-preset")
|
||||
.arg("veryfast")
|
||||
.arg("-hls_time")
|
||||
.arg("5")
|
||||
.arg("3")
|
||||
.arg("-hls_list_size")
|
||||
.arg("100")
|
||||
.arg("-vf")
|
||||
.arg("scale=1080:-2,setsar=1:1")
|
||||
.arg(playlist_file)
|
||||
.output()
|
||||
.expect("Expected this to work..");
|
||||
|
||||
Reference in New Issue
Block a user