Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
cut a mp3 file by ffmpeg
#!/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