Last active
March 6, 2018 08:29
-
-
Save zrong/7821a249b22b96393c81113b3b8d755d to your computer and use it in GitHub Desktop.
shrink.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
############################## | |
# shrink the mp3 files | |
# @author rzeng | |
# @date 2017-02-12 | |
# @update 2018-03-06 | |
# @requirements lame | |
############################## | |
if ! [ "$(which lame)" ];then | |
echo "Install lame first!" | |
exit 127 | |
fi | |
input_file=$1 | |
output_dir=$2 | |
if ! [ -f "$input_file" ];then | |
echo "No input file!" | |
exit 127 | |
fi | |
if ! [ -d "$output_dir" ];then | |
echo "No output dir!" | |
exit 127 | |
fi | |
mp3_file=${input_file%.*}.mp3 | |
new_file=$output_dir/$mp3_file | |
new_dir=$(dirname $new_file) | |
mkdir -p $new_dir | |
echo "convert $input_file to $new_file" | |
lame -m j -V 0 -q 0 -b 45 -B 96 $input_file $new_file |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment