Skip to content

Instantly share code, notes, and snippets.

@deviationist
Last active October 11, 2024 10:24
Show Gist options
  • Save deviationist/593e1eeb4f8e7c14ae72deff74a5eb2f to your computer and use it in GitHub Desktop.
Save deviationist/593e1eeb4f8e7c14ae72deff74a5eb2f to your computer and use it in GitHub Desktop.
Useful FFMPEG Audio bash functions
function flactoaiff() {
if [[ $1 != *.flac ]]; then
echo "Please provide a FLAC-file"
return 1
fi
newFilePath="${1/%.flac/.aiff}"
ffmpeg -y -nostdin -i $1 -write_id3v2 1 -c:v copy $newFilePath
}
function downsample() {
if [[ -z "$1" ]]; then
echo "Please provide an audio-file"
return 1
fi
if ! [[ "$2" =~ ^-?[0-9]+$ ]]; then
echo "Please provide a valid sample rate"
return 1
fi
filePathWithoutExtension="${1%.*}"
fileExtension="${1##*.}"
newFilePath="${filePathWithoutExtension}-downsampled.${fileExtension}"
ffmpeg -y -nostdin -i "${1}" -ar $2 -write_id3v2 1 -c:v copy "${newFilePath}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment