Skip to content

Instantly share code, notes, and snippets.

@zrong
Last active March 6, 2018 08:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zrong/7821a249b22b96393c81113b3b8d755d to your computer and use it in GitHub Desktop.
Save zrong/7821a249b22b96393c81113b3b8d755d to your computer and use it in GitHub Desktop.
shrink.sh
#!/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