mirror of
https://github.com/jarun/nnn.git
synced 2024-11-18 17:09:14 +00:00
32 lines
770 B
Plaintext
32 lines
770 B
Plaintext
|
#!/usr/bin/env sh
|
||
|
|
||
|
# Description: Create an mp3 ringtone out of an audio file in any format
|
||
|
# Needs user to provide start and end where to cut the file
|
||
|
# Input file audio.ext results in audio_ringtone.mp3
|
||
|
# Requires: date, ffmpeg
|
||
|
#
|
||
|
# Shell: POSIX compliant
|
||
|
# Author: Arun Prakash Jana
|
||
|
|
||
|
if ! [ -z "$1" ]; then
|
||
|
echo -n "start (hh:mm:ss): "
|
||
|
read start
|
||
|
st=`date -d "$start" +%s`
|
||
|
|
||
|
echo -n "end (hh:mm:ss): "
|
||
|
read end
|
||
|
et=`date -d "$end" +%s`
|
||
|
|
||
|
if [ $st -ge $et ]; then
|
||
|
echo "error: start >= end"
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
interval=$(( $et - $st ))
|
||
|
|
||
|
outfile=`basename "$1"`
|
||
|
outfile="${outfile%.*}"_ringtone.mp3
|
||
|
|
||
|
ffmpeg -i "$1" -ss "$start" -t "$interval" -vn -sn -acodec libmp3lame -q:a 2 "$outfile"
|
||
|
fi
|