Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AAC not extracting a single chapter in one specific audiobook #12

Closed
Squaredude opened this issue Jan 13, 2020 · 15 comments
Closed

AAC not extracting a single chapter in one specific audiobook #12

Squaredude opened this issue Jan 13, 2020 · 15 comments
Labels
bug Something isn't working

Comments

@Squaredude
Copy link

This problem is weird. Have been testing this across the official Audible players (Android, Windows 10, browser) all day.

The book is "A Game of Thrones" (so, involved in issue #9), the chapter is 45/73. Initially, I thought it was a problem with Audible itself, since I found this post in reddit with this exact problem: https://www.reddit.com/r/audible/comments/5afou8/missing_chapter_within_a_game_of_thrones/

But after resetting most applications and re-downloading the file (only got +20KB of difference in size compared to the one I downloaded 2 years ago, for some reason), the chapter shows up in the players (Android, Win10).

Still, even with this new file, and knowing it contains the chapter in question, it does not get extracted by AAC.

I've tested it with the other books in the series (sans ADWD, which I haven't re-downloaded), and they all get processed correctly by AAC. It must be a problem in this specific file, which only Audible can somehow overlook. Table of contents? Chapter delimiter? I wish I understood a little better to help out.

@audiamus
Copy link
Owner

From your description I would guess that there is an issue with the embedded meta data information in this particular aax file. You can easily test this yourself and run ffmpeg from a console window:
ffmpeg.exe -i myaudiobook.aax
It will list all the chapters in text format, with start and end times in seconds for each of them. AAX Audio Converter simply parses this output. I would expect that the missing chapter will either not not appear in that list or will show up in a slightly modified format so that the parser cannot recognize it.

Now, when you run the audiobook from the App, things will be different. With the app, the meta data is not taken from the aax file itself but from a separate meta data file that will be downloaded by the app together with the aax file.

I have started working on this separate meta data file and hope to get it running for the next version of the program. Main reason for looking into this new file is the list of proper chapter names therein and some users have asked for these. But incorporating this new data will take a bit of time.

As you appear to be affected by the current 24h limit for a book, I suggest two workarounds:

  1. Download the book in parts. Keep the "single file" option. but convert all parts in one invocation.
  2. Or you try the "multiple files, ignoring chapters" option, with an average track length set to the max which is 30 min. Tracks will be split based on silence, so no loss of audio quality during track transition. (But try this second option this with caution. To obtain good precision for silence periods, the program still uses the chapter times to extract temoprary shorter files and then works on those, due a shortcoming of ffmpeg for silence detection. And with a missing chapter, this might go wrong. )

In both cases a playlist will be generated for seamless listening.

@Squaredude
Copy link
Author

Now, when you run the audiobook from the App, things will be different. With the app, the meta data is not taken from the aax file itself but from a separate meta data file that will be downloaded by the app together with the aax file.

I have started working on this separate meta data file and hope to get it running for the next version of the program. Main reason for looking into this new file is the list of proper chapter names therein and some users have asked for these. But incorporating this new data will take a bit of time.

This explains a lot. I thought it was too much of a coincidence for two random people to have the exact same issue. And a meta data file makes a lot of sense. It also explains why the chapters have name in the official players but not in AAC and OA.

@Squaredude
Copy link
Author

Squaredude commented Jan 14, 2020

Download the book in parts. Keep the "single file" option. but convert all parts in one invocation.

If this suggestion was for the missing chapter, I confirm that this doesn't work.

Additionally, there's a small issue. The book in 4 parts gets extracted correctly, and 4 M4A files are created, as well as 4 subfolders ("Part 1" to "Part 4"), each with an empty M3U file. I'm guessing the idea was for a single M3U file linking to the parts in a single subfolder?

Edit: to clarify, I understood your instructions to mean "download the audiobook in parts, and choose the single file per AAX file option".

@audiamus
Copy link
Owner

The way it is supposed to be done is to load all parts into AAX Audio Converter (the Open File dialog supports multiple select, or simply drag them onto its main window), then select them all in the list view (or Ctrl+A) and click "Convert". The program will detect the multi-part book, enter internal multi-part processing and assumes all parts are present. For the "Single file per aax file" mode, five files should be created for your four part book. Four audio files, mp3 or m4a, and one playlist file m3u. And the playlist should have four tracks.

No "part" sub-folders should be created, if invoked like this. If you convert file-by-file, though, you may encounter a bug as I just noticed, obviously a combination that I did not test. When converting a multi-part book for an individual part, a sub-folder "Part #" will be created and the output should go in there. However, this does not make much sense for the singe file per aax option. So, two policies are conflicting here and the result is not as expected. Has to be investigated.

@Squaredude
Copy link
Author

I just tried it with two different books.

Following your instructions, I still get the 4 "Part #" folders with the empty M3U files.

To be clear: I load all 4 files into the program, select them all, and convert using "single file per aax file" in one go.

@audiamus
Copy link
Owner

audiamus commented Jan 16, 2020 via email

@audiamus
Copy link
Owner

I tested a few more option combinations but I cannot produce the result you describe. The closest I get is:

  • Load a 4 part book, all parts.
  • Select part 1, 2 and 4 in the list view but not part 3. This will put the program into the internal "some parts" mode.
  • Click Convert. Subfolders Part 1, Part 2 and Part 4 are created, each with an empty m3u playlist. Apparently a bug but not essential. Because the three converted audio files end up in the main folder. Not good and not intended, but there they are, at least for my tests.

Could it be that for your example the part numbers are not in consecutive order? The program enters "all parts" if part numbers start with 1 and the number of parts equals the highest part number (consecutive order). If conversion is processed for "all parts", no "Part" subfolders will be created.

A suggested bypass, if everything else fails: Convert the book part by part, individual invocations. After each part copy the created audio file somewhere else. When all audio files have been created and saved, use an external tool like Mp3Tag to create the playlist.

@Squaredude
Copy link
Author

Sorry for the delay. I thought it would be better if I uploaded screenshots of the process. Maybe I misunderstood your instructions, or I am unable to relay the results correctly. Here is what happens:

step1
step2
step2b
step3
step4
step5
step6
step7
step8

Additionally, I ran the test with "A Clash of Kings", the second book in the series, which doesn't seem to contain any missing chapters. I get the same:
step6b

Following your suggested bypass makes no difference. I deleted all files created from the steps 1 through 8 demonstration, and tried converting one AAX file at a time. This is what I get:
bypass_step1
bypass_step2

@audiamus
Copy link
Owner

Many thanks for the additional input. That should provide enough clues. Apparently, the program enters the internal "some parts" mode and not, as it should, "all parts". I have to find out why. (Independent of the mess with creating "Part" sub-folders and then not using them.)

However, all the four audio files appear to have been created for both books, albeit without a proper playlist. Or are the m4a files empty, too?

@Squaredude
Copy link
Author

Squaredude commented Jan 17, 2020 via email

@audiamus
Copy link
Owner

audiamus commented Jan 17, 2020

I think I have now been able to kind of reproduce your result. As I said before, AAX Audio converter is entering its internal "some parts" processing mode here. This is the only mode that can create "Part" sub-folders. When the program detects "Part" (or any custom equivalent) in the book title it extracts the part number. For a multiple select conversion it tries to find out whether all parts are present. For this it needs the highest part number and then checks whether part numbers start with 1 and are consecutive. The current implementation src/AaxAudioConverterLib/Book.cs, CheckParts (), line 73 onward, has two flaws here. It sorts the parts by file path but should do it by file title. Then it assumes that the last part has the highest part number. This only works if the file path names reflect the part number order. In almost every case they do. But presumably in your example they don't.

What you can try is to rename your aax files

A_Game_of_Thrones_Part_1.aax
A_Game_of_Thrones_Part_2.aax
A_Game_of_Thrones_Part_3.aax
A_Game_of_Thrones_Part_4.aax

(all in the same folder, of course) and then try again. This will either prove me right or wrong. 😎

I will make two changes: sort by book title (from the embedded tags) and also explicitly search for the highest part number in all parts. Any of the two modifications should solve it.

I will also adjust the "Part" sub-folder creation policy. For "Single file" mode they will only be created if the "extra meta files" option is set, and then the single audio files also go into the "Part" sub-folder. An (empty) playlist will no longer be created.

@audiamus audiamus added the bug Something isn't working label Jan 17, 2020
@Squaredude
Copy link
Author

I can confirm, renaming the AAX files as you suggested gives the expected results: 4 M4A files and 1 M3U file all in the same level. The M3U contains the proper list of M4A files.

It sorts the parts by file path but should do it by file title. Then it assumes that the last part has the highest part number. This only works if the file path names reflect the part number order. In almost every case they do. But presumably in your example they don't.

Exactly. In most of these ASOIAF books, the filename cuts off the word "Part". "A Game of Thrones" has "Pa", and "A Clash of Kings" at "Par", to give a couple of examples.

@audiamus
Copy link
Owner

Excellent, thanks a lot.

The aax file naming scheme is different for downloading via the Audible Download Helper or the Audible App. With the Download Helper, they are never cut short, apparently. Anyway, for the next version of this program, which is supposed to support named chapters, the Audible App file names must stay untouched. Because the cryptic part in it - presumably a hash across user and book id - is the key to the separate meta file which has the chapter names.

@audiamus
Copy link
Owner

audiamus commented Feb 8, 2020

Fixed in version 1.7.

@audiamus audiamus closed this as completed Feb 8, 2020
@Squaredude
Copy link
Author

I'm sorry for taking so long, but I only just now got to try out the newer versions. I can confirm, the program is now extracting all chapters correctly, and also using the chapter titles. Thanks a lot for your hard work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants