sandreas / m4b-tool

m4b-tool is a command line utility to merge, split and chapterize audiobook files such as mp3, ogg, flac, m4a or m4b
MIT License
1.12k stars 78 forks source link

How do you set tags as chapter names? #245

Closed sizzleweet closed 8 months ago

sizzleweet commented 9 months ago

I have a question on chapters.

I have all of my audiobooks in chapterized mp3s.

My mp3s are formatted like this:

I'm trying to figure out how to use m4b tool within auto-m4b to use the title tag instead of the filename as a chapter title when merging the mp3s.

I saw that in the auto-m4b script it runs this command:

m4b-tool merge "$book" -n -q --audio-bitrate="$bit" --skip-cover --use-filenames-as-chapters --no-chapter-reindexing --audio-codec=libfdk_aac --jobs="$CPUcores" --output-file="$m4bfile" --logfile="$logfile"

I know that the --use-filenames-as-chapters switch is the one that is making it use the filenames, but I want it to use the %track% tag for ordering, and the %title% tag for the chapter name. Is this possible?

I'd also be interested in a way to just strip the first part of the file name when doing this, keeping in mind that some books get to 3 digits for the file number. (I'm looking at you Brandon Sanderson)

sandreas commented 9 months ago

I'm trying to figure out how to use m4b tool within auto-m4b to use the title tag instead of the filename as a chapter title when merging the mp3s.

auto-m4b is a third party project I don't personally use, so I can't help you much...

I know that the --use-filenames-as-chapters switch is the one that is making it use the filenames, but I want it to use the %track% tag for ordering, and the %title% tag for the chapter name. Is this possible?

Yes. Without the flag using the title is the default behaviour. I don't know why auto-m4b prefers the filename by default, I think this is not a good decision... maybe the author does not reorganize his files the way I do.

I'd also be interested in a way to just strip the first part of the file name when doing this, keeping in mind that some books get to 3 digits for the file number. (I'm looking at you Brandon Sanderson)

I think m4b-tool default behaviour would be the way you would like this to work. If you would like to be more flexible, I would recommend you to take a look at the custom javascript taggers in tone (https://github.com/sandreas/tone#create-a-javascript-file). With these you can reorder or replace the chapters in the finished m4b file. An example (that does unfortunately not work on big chapter lists) is here: https://github.com/sandreas/tone/issues/40

Another solution could be to just create a chapters.txt and manually set the chapter titles and timestamps.

sandreas commented 8 months ago

Closed due to no further feedback.