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.17k stars 75 forks source link

Feature request: Generate cue sheet #103

Open BenMcLean opened 3 years ago

BenMcLean commented 3 years ago

Given that I have an m4b or wv file that already has chapters encoded into it, I'd like to output a .cue file or other playlist file with the chapter times in it. That way even programs without proper chapter support could still use the chapters

sandreas commented 3 years ago

Hey there,

thanks for thinking about exporting cue sheets. This should not be too complex, m4b-tool already supports splitting by cue sheets... here is an example how an export cue sheet could look like for an audio book:


REM GENRE Fantasy
REM DATE 1999-11-08
PERFORMER "Stephen Fry"
SONGWRITER "J. K. Rowling"
TITLE "Harry Potter and the Philosopher's stone"
FILE "harry-potter-1.m4b" m4b
  TRACK 01 AUDIO
    TITLE "The Boy Who Lived."
    PERFORMER "Stephen Fry"
    INDEX 01 00:00:00
  TRACK 02 AUDIO
    TITLE "The Vanishing Glass"
    PERFORMER "Stephen Fry"
    INDEX 01 06:42:00

Although there is a lot of missing information, it might be helpful to be able to export cue.

Unfortunately it will take some time till this will make it into the code though...

BenMcLean commented 3 years ago

Yeah that'd be perfect. I was thinking of hacking together my own script to do it with Python or something bare bones like that, but if you can put it in m4b-tool instead, that'd be great. Appreciate anything you can do, whenever. :)

sandreas commented 3 years ago

If you just need the metadata (regardless in what format), the latest pre-release already is able to export some formats within the meta command - this is where the cue export would also be implemented. There is not only a "chapters" option - it is also possible to --export-cover or --export-description. See m4b-tool help meta for a detailed list of all available options. Some examples:

# use default export filename my-audio-book.chapters.txt
m4b-tool meta my-audio-book.m4b --export-chapters

# use specific filename
m4b-tool meta my-audio-book.m4b --export-chapters=my-chapter-export.txt

# export everything in every format that is supported
m4b-tool meta my-audio-book.m4b --export-all

You can also import chapters the same way, so an export, then editing and then import is no problem, while --import-all will have a priority of what to import, since there are conflicting formats...

sandreas commented 3 years ago

Ok, after some research it seems that cue is clearly not meant for audiobooks (although that does not mean, that there is no way to abuse / workaround it to fit audiobooks needs). Here's why:

So for now i have to set this back, since m4b-tool is mainly used for audiobooks, but I'll leave this ticket open because it also can be used for other audio files and the topic is pretty interesting.

A good (german) resource for cue sheets is: https://www.audiohq.de/viewtopic.php?id=2695

gitoss commented 3 weeks ago
  • Cuesheets can have a Maximum of 99 tracks (00-99) - so if there is an audiobook with more than 99 Chapters, a "workaround" in form of sub-indexes would be required

I'm happily using .cue as a sidecar for audiobooks, and chapters of several hundred indexes work just fine with all audio players I've tied (inluding mobile ones for Android).

Yes. sub-chapters would be nicer for navigation, but because the actual mp3 chatper spec (mp3merge supports it) is too compilcated and thus was never widely adopted imho cue is the way to go for mp3. For other formats like mp4 and ogg the chapters can be embedded.