Skip to content

Commit

Permalink
🚀 Speed up fps_changer on apple silicons via -c:v hevc_videotoolbox
Browse files Browse the repository at this point in the history
  • Loading branch information
tgotwig committed Jul 23, 2024
1 parent 91bda20 commit bf8c3c4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <TMP_DIR>/fps_changer.
- Selector now case-insensitive, so it selects mp4 and MP4 etc.

Expand Down
13 changes: 10 additions & 3 deletions src/commanders/_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Child, std::io::Error> {
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
);

Expand All @@ -35,7 +41,7 @@ pub fn merge_with_chapters(
output_file_for_chapterer: &str,
) -> Result<Child, std::io::Error> {
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
Expand All @@ -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()
);
Expand Down

0 comments on commit bf8c3c4

Please sign in to comment.