Created
May 5, 2016 19:20
-
-
Save kaleksandrov/58eed0d9676db0f7fec74c56a3b26631 to your computer and use it in GitHub Desktop.
Converts the given video file to an audio one.
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/sh | |
case $# in | |
1) | |
FROM="$1" | |
TO="$1" | |
;; | |
2) | |
FROM="$1" | |
TO="$2" | |
;; | |
*) | |
echo "Usage: $0 <from-folder-or-file> <optional:to-folder-or-file>" | |
exit 1 | |
;; | |
esac | |
IFS='' | |
if ! [ -e "$FROM" ] | |
then | |
echo "The source path is invalid: $FROM" | |
exit 2 | |
elif [ -d "$FROM" ] | |
then | |
FROM=$FROM/*.* | |
if ! [ -d "$TO" ] | |
then | |
echo "The destination file does not exists: $TO" | |
exit 3 | |
fi | |
elif [ -f "$FROM" ] | |
then | |
FROM=$FROM | |
if [ -e "$TO" -a -d "$TO" ] | |
then | |
TO="$TO$(basename $FROM)" | |
fi | |
fi | |
for FILE in $FROM | |
do | |
SIMPLE_FILE="$(basename $FILE)" | |
EXTENSION="${SIMPLE_FILE##*.}" | |
FILENAME="${SIMPLE_FILE%.*}" | |
echo '------------' | |
ffmpeg -i "$FILE" -vn -acodec libmp3lame -ac 2 -ab 320k -ar 48000 "$TO/$FILENAME.mp3" | |
echo '------------' | |
done | |
unset IFS |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment