Last active
December 25, 2015 12:59
-
-
Save rjeczalik/6980503 to your computer and use it in GitHub Desktop.
converts m4a to ogg (lazy way to workaround an issue with most recent mpd from homebrew, which apparently does not like m4a)
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
#!/usr/bin/env bash | |
to-ogg() { | |
local src= | |
local dst= | |
{ | |
[ ${#} == 0 ] && src=. && dst=. | |
} || { | |
[ ${#} == 1 ] && | |
[ -d "${1}" ] && src="${1}" && dst="${src}" | |
} || { | |
[ ${#} == 2 ] && | |
[ -d "${1}" ] && src="${1}" && | |
[ -d "${2}" ] && dst="${2}" | |
} && { | |
local log=`mktemp /tmp/to-ogg.XXXXXX` | |
local src_file | |
for src_file in "${src}"/*.m4a; do | |
local dst_filename="${src_file##*/}" | |
local dst_file="${dst}/${dst_filename%*m4a}ogg" | |
[ -f "${dst_file}" ] && { | |
echo "# skipping \"${src_file}\", \"${dst_file}\" already exists" | |
} || { | |
echo "# converting \"${src_file}\"" | |
ffmpeg -i "${src_file}" -acodec vorbis -strict -2 -aq 60 -vn -ac 2 "${dst_file}" 1>>"${log}" 2>&1 || echo "! converting \"${src_file}\" failed" | |
} | |
done | |
echo "# [ log ${log} ]" | |
return 0 | |
} | |
echo "usage: to-ogg [<src-dir=./> [<dest-dir=src-dir>]]" 1>&2 | |
return 1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment