Skip to content

Instantly share code, notes, and snippets.

@butuzov
Created August 10, 2018 06:07
Show Gist options
  • Save butuzov/fa7d456ebc3ec0493c0a10b73800bf42 to your computer and use it in GitHub Desktop.
Save butuzov/fa7d456ebc3ec0493c0a10b73800bf42 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
@fikovnik
Copy link

I ended up with a similar approach, using just ffmpeg and bash: https://gist.github.com/fikovnik/963fd95b3ffbde2d139d39dd1d2c73a2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment