1
- use std:: { fs, process:: Command } ;
1
+ use std:: { fs, io , process:: Command } ;
2
2
3
3
fn run_command ( command : & str ) {
4
4
let cmd = Command :: new ( "sh" )
@@ -20,7 +20,7 @@ fn run_command(command: &str) {
20
20
println ! ( "{}" , result) ;
21
21
}
22
22
23
- pub fn create_preview_gif ( input : & str , subpath : & str , output : & str ) {
23
+ pub fn create_preview_gif ( input : & str , subpath : & str , output : & str ) -> io :: Result < ( ) > {
24
24
let path = format ! ( "{}/{}" , output, subpath) ;
25
25
if fs:: metadata ( & path) . is_err ( ) {
26
26
fs:: create_dir_all ( & path) . unwrap ( ) ;
@@ -31,9 +31,10 @@ pub fn create_preview_gif(input: &str, subpath: &str, output: &str) {
31
31
) ;
32
32
33
33
run_command ( & command) ;
34
+ Ok ( ( ) )
34
35
}
35
36
36
- pub fn create_preview_image ( input : & str , subpath : & str , output : & str ) {
37
+ pub fn create_preview_image ( input : & str , subpath : & str , output : & str ) -> io :: Result < ( ) > {
37
38
let path = format ! ( "{}/{}" , output, subpath) ;
38
39
if fs:: metadata ( & path) . is_err ( ) {
39
40
fs:: create_dir_all ( & path) . unwrap ( ) ;
@@ -45,9 +46,10 @@ pub fn create_preview_image(input: &str, subpath: &str, output: &str) {
45
46
) ;
46
47
47
48
run_command ( & command) ;
49
+ Ok ( ( ) )
48
50
}
49
51
50
- pub fn create_thumbnails ( input : & str , subpath : & str , output : & str ) {
52
+ pub fn create_thumbnails ( input : & str , subpath : & str , output : & str ) -> io :: Result < ( ) > {
51
53
println ! ( "\n create_thumbnails" ) ;
52
54
53
55
let thumbs_path = format ! ( "{}/{}" , output, subpath) ;
@@ -63,9 +65,10 @@ pub fn create_thumbnails(input: &str, subpath: &str, output: &str) {
63
65
) ;
64
66
65
67
run_command ( & command) ;
68
+ Ok ( ( ) )
66
69
}
67
70
68
- pub fn create_hls_encoding ( input : & str , subpath : & str , output : & str ) {
71
+ pub fn create_hls_encoding ( input : & str , subpath : & str , output : & str ) -> io :: Result < ( ) > {
69
72
println ! ( "\n pub create_hls_encoding" ) ;
70
73
71
74
let hls_path = format ! ( "{}/{}" , output, subpath) ;
@@ -96,4 +99,5 @@ pub fn create_hls_encoding(input: &str, subpath: &str, output: &str) {
96
99
-hls_playlist_type {}/vod \
97
100
{}/720p_%03d.m3u8 {}/720p.m3u8", input, hls_path, hls_path, hls_path) ;
98
101
run_command ( & command) ;
102
+ Ok ( ( ) )
99
103
}
0 commit comments