m4b-tool icon indicating copy to clipboard operation
m4b-tool copied to clipboard

Feature request: Generate cue sheet

Open BenMcLean opened this issue 5 years ago • 5 comments
trafficstars

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

BenMcLean avatar Nov 17 '20 15:11 BenMcLean

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...

sandreas avatar Nov 17 '20 16:11 sandreas

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. :)

BenMcLean avatar Nov 17 '20 21:11 BenMcLean

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 avatar Nov 18 '20 06:11 sandreas

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:

  • Tracks cannot be shorter than 4 seconds, which might be a problem with short intro chapters
  • 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
  • Although these Tracks can have sub-indexes (INDEX 01 - INDEX 99) there is no real specification for naming of sub-indexes (there is a way using comments with REM, but this is non standard), so Chapter names would not be possible in every case
  • Many of the metadata fields in other formats (e.g. ffmetadata) are not specified or non standard

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

sandreas avatar Nov 20 '20 18:11 sandreas