Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save greg-randall/a1b02ee046f50d47fa6f2e543ac04085 to your computer and use it in GitHub Desktop.
Save greg-randall/a1b02ee046f50d47fa6f2e543ac04085 to your computer and use it in GitHub Desktop.
Convert a folder one m4b at a time to opus. Edit line 4 for more or less any file format that contains audio.
#!/bin/bash
# Loop over all m4b files in the current directory
for input in *.m4b
do
# Print a message indicating the file being processed
echo "Processing file $input..."
# Use ffmpeg to convert the m4b file to a wav file
ffmpeg -i "$input" "${input%.*}.wav"
# Use opusenc to convert the wav file to an opus file
opusenc --downmix-mono --bitrate 32 --vbr "${input%.*}.wav" "${input%.*}.opus"
# Remove the wav file
rm "${input%.*}.wav"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment