audible-cli icon indicating copy to clipboard operation
audible-cli copied to clipboard

Decrypt options

Open CoolJoe72 opened this issue 1 year ago • 4 comments

while running audible decrypt -ars I get the following error and it stops.

debug: Audible-cli version: 0.2.4
…
Skip /…/Atomic_Habits_An_Easy__Proven_Way_to_Build_Good_Habits__Break_Bad_Ones-AAX_22_64.m4b: already exists
…
size=       2kB time=-577014:32:22.77 bitrate=N/A speed=N/A    
Using chapters from /…/B01MEH7DLA_Breaking_the_Habit_of_Being_Yourself_How_to_Lose_Your_Mind_and_Create_a_New_One-chapters.json
error: Chapter mismatch
--- or ---
size=       2kB time=-577014:32:22.77 bitrate=N/A speed=N/A    
error: Chapter file /…/B01MEH7DLA_Breaking_the_Habit_of_Being_Yourself_How_to_Lose_Your_Mind_and_Create_a_New_One-chapters.json not found.

Which is fine (not sure if "Chapter mismatch" is a bug or just Audible) I'll deal with the file later, but it would be really nice if it continued onto the other files and just skipped decrypting for the ones with errors.

Also would it be possible (and maybe it should put this in a separate issue/feature request) to add an option to compleatly remove the Audible Brand Intro and Outro from the m4b?

CoolJoe72 avatar Aug 15 '23 14:08 CoolJoe72

Chapter mismatch occur, if the number of chapters requested from the API are not equal to the number of chapters from the audio file. You can try to add -t to ignore this error. So the full command is audible decrypt -arst.

Also would it be possible (and maybe it should put this in a separate issue/feature request) to add an option to compleatly remove the Audible Brand Intro and Outro from the m4b?

I does not know if ffmpeg support cutting without reencoding. The -s flag separates the intro and outro. If you can tell me how ffmpeg can cut off chapters, then it should be possible.

mkb79 avatar Aug 15 '23 16:08 mkb79

What I have found:

  • It looks like the Intro and Outro times are only in the -chapters.json
  • the In/Ou-tro have 3 different length sets that I've observed so far
    • brandIntroDurationMs: 3924 or 1904 or 0
    • brandOutroDurationMs: 4945 or 4969 or 0
  • unless there's another source a -chapers.json file will be needed to strip the branding. Or one could always guess but I'm not sure which is worse the branding or clipped audio/words

As for ffmpeg it can seek to position with -ss 1904ms (brandIntroDurationMs:1904) placed before -i sourcefile and with the -t 21340439ms (runtime_length_ms:21347312 - (brandIntroDurationMs:1904 + brandOutroDurationMs:4969)) before the outfile using the copy command, but it's more accurate (not sure it needs to be though) when transcoding by default.

ffmpeg -v quiet -stats -activation_bytes **** -ss 1.904 -i sourcefile.aax -t 21340.439 -c copy outfile.m4b

note: I've noticed if -ss is placed after the -i sourcefile the cover image gets removed. :thinking:

CoolJoe72 avatar Aug 16 '23 20:08 CoolJoe72

As for the Chapter mismatch it looks like it happens when audible -chapters.json has "sub" chapters

"chapters": [
    {
        "length_ms": 44559,
        "start_offset_ms": 0,
        "start_offset_sec": 0,
        "title": "Opening Credits"
    },
    {
        "chapters": [
            {
                "length_ms": 43229,
                "start_offset_ms": 67732,
                "start_offset_sec": 68,
                "title": "1. Introduction to Session One"
            },
            ………
            {
              "length_ms": 289158,
              "start_offset_ms": 3200982,
              "start_offset_sec": 3201,
              "title": "10. Exploring Dorsal and Sympathetic Survival States"
            }
        ],
        "length_ms": 23173,
        "start_offset_ms": 44559,
        "start_offset_sec": 45,
        "title": "Session One: Exploring the Autonomic Pathways"
    },
    Chapter #0:0: start 0.000000, end 44.558980
    Metadata:
      title           : Opening Credits
    Chapter #0:1: start 44.558980, end 67.731995
    Metadata:
      title           : Session One: Exploring the Autonomic Pathways
    Chapter #0:2: start 67.731995, end 110.960998
    Metadata:
      title           : 1. Introduction to Session One
………
    Chapter #0:11: start 3200.981995, end 3490.140000
    Metadata:
      title           : 10. Exploring Dorsal and Sympathetic Survival States

168364462X_Befriending_Your_Nervous_System_Looking_Through_the_Lens_of_Polyvagal_Theory-ffprobe.txt 168364463X_Befriending_Your_Nervous_System_Looking_Through_the_Lens_of_Polyvagal_Theory-chapters.json.txt

CoolJoe72 avatar Aug 16 '23 20:08 CoolJoe72

Thank you for this information. I will take a look on this.

The chapter file contains the response from the API and not the file. I can request flatten chapters instead a tree. Here you can find information about the endpoint.

More coming soon.

mkb79 avatar Aug 17 '23 07:08 mkb79

#170 Thank You!!!

After testing a few files it seems that the updates in Release v0.3.2b2 for the chapter-type work well. However it should be noted that most of the downloaded chapter.json files will not match the default chapters in the .aax files, but will closer match the .aaxc files. You can always use the -f (force) flag or -t (skip) flag, but, as with anything use with caution!

CoolJoe72 avatar May 27 '24 20:05 CoolJoe72