@@ -3,22 +3,26 @@ use std::process::Command;
33use anyhow:: { Context , Result } ;
44use tempfile:: TempDir ;
55
6+ use crate :: utils:: IMG_EXT ;
7+
68const PROGRAM : & str = "ffmpeg" ;
79
10+ #[ cfg( target_os = "macos" ) ]
11+ const INST_CMD : & str = "brew install ffmpeg" ;
12+ #[ cfg( not( target_os = "macos" ) ) ]
13+ const INST_CMD : & str = "apt-get install ffmpeg" ;
14+
815/// checks if ffmpeg is available
916pub fn check_for_ffmpeg ( ) -> Result < ( ) > {
1017 let out = Command :: new ( PROGRAM )
1118 . arg ( "-version" )
1219 . output ( )
1320 . with_context ( || {
14- format ! (
15- "There is an issue with '{}', please install: `brew install {}`" ,
16- PROGRAM , PROGRAM
17- )
21+ format ! ( "There is an issue with '{PROGRAM}', please install: `{INST_CMD}`" )
1822 } ) ?;
1923
2024 if !String :: from_utf8 ( out. stdout . to_vec ( ) )
21- . with_context ( || format ! ( "Unable to parse the `{} -version`" , PROGRAM ) )
25+ . with_context ( || format ! ( "Unable to parse the `{PROGRAM } -version`" ) )
2226 . unwrap ( )
2327 . contains ( "--enable-libx264" )
2428 {
@@ -37,7 +41,7 @@ pub fn generate_mp4_with_ffmpeg(
3741 tempdir : & TempDir ,
3842 target : & str ,
3943) -> Result < ( ) > {
40- println ! ( "🎉 🎬 Generating {}" , & target ) ;
44+ println ! ( "🎉 🎬 Generating {target}" ) ;
4145 Command :: new ( PROGRAM )
4246 . arg ( "-y" )
4347 . arg ( "-r" )
@@ -48,7 +52,7 @@ pub fn generate_mp4_with_ffmpeg(
4852 . arg ( "-pattern_type" )
4953 . arg ( "glob" )
5054 . arg ( "-i" )
51- . arg ( tempdir. path ( ) . join ( "*.tga" ) )
55+ . arg ( tempdir. path ( ) . join ( format ! ( "*.{IMG_EXT}" ) ) )
5256 . arg ( "-vcodec" )
5357 . arg ( "libx264" )
5458 . arg ( "-pix_fmt" )
@@ -59,6 +63,6 @@ pub fn generate_mp4_with_ffmpeg(
5963 // end of fix
6064 . arg ( target)
6165 . output ( )
62- . with_context ( || format ! ( "Cannot start '{}' to generate the final video" , PROGRAM ) )
66+ . with_context ( || format ! ( "Cannot start '{PROGRAM }' to generate the final video" ) )
6367 . map ( |_| ( ) )
6468}
0 commit comments