Skip to content

Instantly share code, notes, and snippets.

@zeGolem
Last active August 20, 2022 09:19
Show Gist options
  • Save zeGolem/9d2a4d02e907a8e60e3403bcdbbe9ebd to your computer and use it in GitHub Desktop.
Save zeGolem/9d2a4d02e907a8e60e3403bcdbbe9ebd to your computer and use it in GitHub Desktop.
Script to quickly generate nightcore versions of your favorite songs! (using ffmpeg)
#!/bin/bash
# ./nightcorify.sh $input_file $output_file [$speed]
set -ex;
input_file=$1;
output_file=$2;
speed=${3-1.25}
[[ $input_file = "" ]] && echo "You must specify an input file" && exit 1;
[[ $output_file = "" ]] && echo "You must specify an output file" && exit 1;
sample_rate=$( \
(ffprobe "$input_file" -select_streams a:0 -show_entries stream=sample_rate 2> /dev/null) \
| grep sample_rate \
| cut -d'=' -f2 \
);
echo "Sample rate: $sample_rate Hz";
ffmpeg -i "$input_file" -af "asetrate=$sample_rate*$speed" "$output_file";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment