Last active
October 11, 2024 10:24
-
-
Save deviationist/593e1eeb4f8e7c14ae72deff74a5eb2f to your computer and use it in GitHub Desktop.
Useful FFMPEG Audio bash functions
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
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