Skip to content

Commit 72f7131

Browse files
committed
fix: split up hls and dash files into sub paths
1 parent 9214755 commit 72f7131

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

src/ffmpeg.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -68,20 +68,17 @@ pub fn create_thumbnails(input: &str, subpath: &str, output: &str) -> io::Result
6868
pub fn create_hls_encoding(input: &str, subpath: &str, output: &str) -> io::Result<()> {
6969
println!("\npub create_hls_encoding");
7070

71-
let hls_path = format!("{}/{}", output, subpath);
71+
let hls_path = format!("{}/{}/hls", output, subpath);
7272

7373
if fs::metadata(&hls_path).is_err() {
7474
fs::create_dir_all(&hls_path)?;
7575
}
7676

77-
// TODO: Sub add paths
78-
// let paths = ["hls", "dash"];
79-
// for path in paths {
80-
// let p = format!("{}/{}", path, output);
81-
// if !fs::metadata(&p).is_ok() {
82-
// fs::create_dir_all(&p)?;
83-
// }
84-
// }
77+
let dash_path = format!("{}/{}/dash", output, subpath);
78+
79+
if fs::metadata(&dash_path).is_err() {
80+
fs::create_dir_all(&dash_path)?;
81+
}
8582

8683
let command = format!("ffmpeg -stream_loop 0 -i {} \
8784
-map 0 -map 0 -map 0 -c:a aac -c:v h264_videotoolbox -allow_sw 1 \
@@ -92,9 +89,9 @@ pub fn create_hls_encoding(input: &str, subpath: &str, output: &str) -> io::Resu
9289
-keyint_min 120 -g 120 -sc_threshold 0 -b_strategy 0 -ar:a:1 22050 -use_timeline 1 -use_template 1 \
9390
-window_size 0 -adaptation_sets \"id=0,streams=v id=1,streams=a\" -hls_playlist 1 -seg_duration 4 \
9491
-streaming 0 -f dash \
95-
-hls_segment_filename \
9692
-hls_playlist_type {}/vod \
97-
{}/720p_%03d.m3u8 {}/720p.m3u8", input, hls_path, hls_path, hls_path);
93+
{}/720p_%03d.m3u8 {}/720p_%03d.m3u8", input, hls_path, hls_path, dash_path);
9894
run_command(&command)?;
9995
Ok(())
10096
}
97+
// -hls_segment_filename \

0 commit comments

Comments
 (0)