Merging multiple mp3 files into an audiobook with chapters

I recently found the 3 Lord of the Rings audiobooks I bought from Phil Dragash some years back, as I was digging through my NAS. Each book is split into about 20 mp3 files, which makes it a bit unwieldy for me. As I mostly listen to audiobooks when I'm going to sleep, I oftentimes have to find the last part I remember listening to and start again from there the next day.

Luckily, BookPlayer solves this for me, via its "Stop after this chapter" feature. However, to import these books into the app, I needed to merge the mp3 files into a full-fledge audiobook m4b file, with chapter metadata.

After digging a little bit, this is what I found:

$ docker run \
    -it \  # to see the output of the containerized process in the terminal
    --rm \  # delete the container once the conversion ends
    -u $(id -u):$(id -g) \  # Use the same UID and GID than in the host to avoid permission issues
    -v "$(pwd)/audiobooks":/mnt \  # mount the ./audiobooks folder into /mnt in the container via a docker volume
    sandreas/m4b-tool:latest \  # cf https://hub.docker.com/r/sandreas/m4b-tool
        merge \  # subcommand in charge of merging the mp3 files into a single m4b file
            "/mnt/The Fellowship of the Ring" \  # directory in which the audio files are located
            --output-file "/mnt/The Fellowship of the Ring.m4b" \  # name of the generated m4b file
            --series "The Lord of the Rings" \  # name of the book series
            --name="The Fellowship of the Ring" \  # title of the book
            --series-part=1 \  # book number in the series
            --artist "J.R.R Tolkien" \  # writer's name
            --albumartist="Phil Dragash" \  # narrator's name
            --use-filenames-as-chapters \  # generate a chapter per mp3 file
            --cover "/mnt/The Fellowship of the Ring/cover.jpg" \  # path to the cover image
            --jobs=8 \  # I used number of CPUs - 2
            --audio-channels=2 \  # 1=mono, 2=stereo
            --audio-samplerate=44100  # I used the same as in the input files

Here's the result after I imported the result m4b file into BookPlayer.

Comments