Last active
November 20, 2021 02:23
-
-
Save deviationist/d4f1f346adcce23000d83735eb540fef to your computer and use it in GitHub Desktop.
FFMPEG reduce audio sample rate (AIFF, WAV)
This file contains hidden or 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/bash | |
| toConvertFolder="to-convert/" | |
| convertedFolder="converted/" | |
| maxKhz=48000 | |
| mkdir -p $convertedFolder | |
| formats=( "aiff" "wav" ) | |
| for i in "${formats[@]}" | |
| do | |
| # Reduce sample rate | |
| find $toConvertFolder -type f -name "*.${i}" | while read line; do | |
| tempFilename="${line/%.${i}/-temporary.${i}}" | |
| mv "${line}" "${tempFilename}" | |
| ffmpeg -y -nostdin -i "${tempFilename}" -ar $maxKhz -write_id3v2 1 -c:v copy "${line}" && rm "${tempFilename}" && mv "${line}" "${convertedFolder}" | |
| mv "${tempFilename}" "${line}" 2>/dev/null | |
| done | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment