From bf8c3c45e26b883379dd1cb9a98a5e08c8b0233e Mon Sep 17 00:00:00 2001 From: Thomas Gotwig Date: Tue, 23 Jul 2024 20:42:19 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=80=20Speed=20up=20fps=5Fchanger=20on?= =?UTF-8?q?=20apple=20silicons=20via=20-c:v=20hevc=5Fvideotoolbox?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://github.com/tgotwig/vidmerger/issues/46 --- CHANGELOG.md | 1 + src/commanders/_cmd.rs | 13 ++++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f6a20c..c3c2d1f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +- Speed up fps_changer on Apple Silicons via -c:v hevc_videotoolbox. - Videos with changed fps from fps_changer will be stored in /fps_changer. - Selector now case-insensitive, so it selects mp4 and MP4 etc. diff --git a/src/commanders/_cmd.rs b/src/commanders/_cmd.rs index b06652a..a506046 100644 --- a/src/commanders/_cmd.rs +++ b/src/commanders/_cmd.rs @@ -11,13 +11,19 @@ use term_painter::Color::BrightBlue; use term_painter::ToStyle; lazy_static! { + static ref IS_APPLE_SILICON: bool = cfg!(target_arch = "aarch64"); + static ref HEVC_ARG: String = if *IS_APPLE_SILICON { + String::from("-c:v hevc_videotoolbox") + } else { + String::from("") + }; static ref MATCHES: ArgMatches = Cli::init().get_matches(); static ref VERBOSE: bool = MATCHES.is_present("verbose"); } pub fn merge(input: String, output: &String) -> Result { let cmd = format!( - "ffmpeg -y -f concat -safe 0 -i {} -c:v hevc_videotoolbox -map 0 -c copy {}", + "ffmpeg -y -f concat -safe 0 -i {} -map 0 -c copy {}", input, output ); @@ -35,7 +41,7 @@ pub fn merge_with_chapters( output_file_for_chapterer: &str, ) -> Result { let cmd = format!( - "ffmpeg -y -i {} -i {} -c:v hevc_videotoolbox -map 0 -map_metadata 1 -codec copy {}", + "ffmpeg -y -i {} -i {} -map 0 -map_metadata 1 -codec copy {}", &input_file_for_chapterer, file_path.to_str().unwrap(), output_file_for_chapterer @@ -61,8 +67,9 @@ pub fn adjust_fps_by_ffmpeg( new_file_location: PathBuf, ) -> PathBuf { let cmd = format!( - "ffmpeg -i {} -c:v hevc_videotoolbox -r {} {}", + "ffmpeg -i {} {} -r {} {}", file_to_merge.to_str().unwrap(), + *HEVC_ARG, fps_goal, new_file_location.to_str().unwrap() );