Skip to content

Instantly share code, notes, and snippets.

@bepcyc
Last active June 3, 2016 15:08
Show Gist options
  • Save bepcyc/ccd6321c3a2e8e1cae3d7579f617f61d to your computer and use it in GitHub Desktop.
Save bepcyc/ccd6321c3a2e8e1cae3d7579f617f61d to your computer and use it in GitHub Desktop.
Determine audio file overall bit rate in Kbps.
# sudo apt-get install mediainfo
# input is a file or a glob mask (first file is taken in this case)
# output is one decimal number - bitrate of a file. Zero if file not found.
get_bitrate() {
F="${1}"
FOUND=$(compgen -G "${F}" | head -n1)
if [ -z "${FOUND}" ]
then
echo 0
else
echo $(mediainfo "${FOUND}" | grep "Overall bit rate " | tail -n1 | sed 's/.*: \(.*\) .*/\1/' | sed 's/[^0-9\\.]//g')
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment