Created
February 12, 2017 11:38
-
-
Save zrong/f470b14dc51ecc5c62ae9d09671ba9ce to your computer and use it in GitHub Desktop.
cut a mp3 file by ffmpeg
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 | |
############################## | |
# cut a mp3 file | |
# @author rzeng | |
# @date 2017-02-12 | |
# @requirements ffmpeg | |
############################## | |
if ! [ "$(which ffmpeg)" ];then | |
echo "Install ffmpeg first!" | |
exit 127 | |
fi | |
time=$1 | |
input_file=$2 | |
output_file=$3 | |
if [ -z "$time" ];then | |
echo 'Give me time!' | |
exit 127 | |
fi | |
if ! [ -f "$input_file" ];then | |
echo 'Give me a input file please!' | |
exit 127 | |
fi | |
if ! [ -f "$output_file" ];then | |
output_file=${input_file}.cut.mp3 | |
fi | |
ffmpeg -i $input_file -t $time -acodec copy $output_file |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment