geigi / cozy

🎧 Listen to audio books 📚 on Linux
https://cozy.sh
GNU General Public License v3.0
1.11k stars 85 forks source link

Cozy does not detect chapters in certain m4b audiobooks, while VLC does #547

Open archisman-panigrahi opened 3 years ago

archisman-panigrahi commented 3 years ago

Bug/Feature description

In certain audiobooks, Cozy does not detect the chapters (it renders the whole audiobook as a single chapter), while VLC does detect the chapters.

Steps to reproduce

  1. Download the m4b file of Tales from Shakespeare from LibriVox (it is in the public domain).

  2. Load the Audiobook in Cozy. It plays the whole 8 hour 31 minutes long audiobook as a single chapter. image

  3. Open the Audiobook in VLC, which shows the chapters (see screenshot). image VLC shows the chapters, e.g. Macbeth (I marked certain chapters with red to illustrate)

The similar issue is present when I download other audiobooks from LibriVox. Instead, if I generate the m4b from mp3 files using the m4b-tool, then this issue is absent.

System Information

geigi commented 3 years ago

Hey :) Thanks for your detailed bug report.

I tested the file you provided and the metadata library mutagen, which Cozy is using to read the chapters from m4b files, does not find any chapters within this file.

I suggest to open an issue on the mutagen project with your example file. Maybe @mweinelt can have a look if you're still around? :)

archisman-panigrahi commented 3 years ago

I don't know how to use mutagen. If I tell them that cozy is unable to find chapters, and it uses mutagen, they might say "ask cozy developers instead".

What is the best way to proceed?

geigi commented 3 years ago

I think you misunderstood slightly. You don't have to use mutagen. If you provide them the audio file and the explanation that no chapters are detected within this file it should be enough information :) you can also highlight me in the issue at mutagen so if any questions come up that you don't understand I might be able to help out.

geigi commented 3 years ago

If you still feel unsure about it let me know I can also write an issue. But it will probably take some time ...

archisman-panigrahi commented 3 years ago

I will create a bug report, and I will ping you if there is any confusion there.

Edit: I have created the issue.

geigi commented 3 years ago

Sounds good!

jeois commented 1 year ago

I also have this issue. It's especially frustrating for audiobooks because they often don't split the production into tracks, so chapters are necessary.

Btw, I commented on mutagen's issue, but there hasn't been any movement in almost 2 years. Even if this is an outdated chapter marking method, newer works are still being produced with this issue, so it's still very relevant.

I've tried many audio players and only VLC and qmmp can actually handle mp4 chapters consistently, but they're not designed for audio books. I've noticed tracking issues with VLC and long audio files. (pause/play skips a few seconds)

In any case, I like the layout of Cozy and would prefer it, but the lack of chapters for many books prevents me from using it more.

mweinelt commented 1 year ago

Nobody at mutagen seems to have the bandwidth to implement this. I wouldn't count on this happening anytime soon unless anyone steps up. This is basically about knowing some python and the struct module to dissect the mp4 file.

Won't be me this time, sorry.

jeois commented 1 year ago

That's unfortunate, but it's totally fine if nobody has time.

Btw, DeadBeef handles mp4 chapters, but it has issues if that data is in a separate .cue file. Cozy does see chapters in .cue files, but often it fails to recognize chapters in single .m4b files.

I know this is getting off-topic, but does anyone know which players besides qmmp can actually handle this apparently misused standard? If so, perhaps we can borrow their libraries to parse the data? Many apps claim to have this feature, but I only know of a few where it's implemented thoroughly.

A few media players designed for video such as VLC and Haruna (mpv based) do have consistent chapters, but the only way to interact is through hash marks on the seek bar or in awkward menus.

qmmp uses many plugins in combination. I'm not sure if FFmpeg, libmad or its CUE plugin that's handling this chapter metadata, perhaps all of them together in different format scenarios. I noticed that DeadBeef also uses libmad for mpeg decoding, so that may be the common denominator?

mojolo commented 12 months ago

You can use mp4chaps from the mp4v2 project to fix this.

Using the following command will convert the weirdo chapters into modern, compliant Quicktime and Nero chapters: mp4chaps -cQN FILENAME.m4b

To batch convert a directory of files, just run: for m4b in *.m4b; do mp4chaps -cQN "${m4b}"; done

Explanation of the -cQN actions

FYI, the manpage for mp4chaps is available here.

LSeelig commented 2 months ago

for m4b in *.m4b; do mp4chaps -cQN "${m4b}"; done

Could this be integrated into Cozy? Or could mp4v2 replace mutagen completely? I see it's a C/C++ project, so I don't know if we'd need bindings or something.