Skip to content

Instantly share code, notes, and snippets.

@atomicpapa
Forked from butuzov/mp3 to m4b.md
Created August 14, 2021 22:06
Show Gist options
  • Save atomicpapa/cb0cf6f6683ce60492461dae045449be to your computer and use it in GitHub Desktop.
Save atomicpapa/cb0cf6f6683ce60492461dae045449be to your computer and use it in GitHub Desktop.
Convert mp3's to m4b using `ffmpeg`

Let's imagine we have a lot of mp3 files ( forexample one of the pluralsite courses converted to mp3 ).

URL=https://www.pluralsight.com/courses/run-effective-meetings
PASS=pass
USER=user
OUTPUT="%(playlist_index)s. %(title)s-%(id)s.%(ext)s"
youtube-dl --username $USER --password $PASS -o $OUTPUT --extract-audio --audio-format mp3 $URL

Once you have a list of files we can start converting it first by combining all mp3 into one, and then converting it to m4a/m4b format.

  ls | grep "mp3" | awk '{printf "file |%s|\n", $0}' | sed -e "s/|/\'/g" > list.txt \
  && ffmpeg -f concat -safe 0 -i list.txt -c copy output.mp3 \
  && ffmpeg -i output.mp3 output.m4a \
  && mv output.m4a output.m4b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment