TheMetalCenter / m4b-mp3-chapters-from-cuesheets

merge audiobooks or podcasts without re-encoding (remuxing only) to single m4b with quicktime/nero chapters or mp3 with id3v2 chapters using cuesheets; also allows for renaming/editing chapters
23 stars 0 forks source link

iTunes shows corrupted track length #15

Open AudioAnchorite opened 3 months ago

AudioAnchorite commented 3 months ago

Two M4B audiobooks are displaying incorrect track lengths in iTunes and on iOS after processing the chapters with m4b_add-chapters.bat

The track lengths are both displaying track length upwards of 780 minutes

313366523-138d6a90-6319-45c5-bfce-05b2fa73f8ae

I see these messages after the processing completes:

[out#0/mp4 @ 0000022c05917080] video:0kB audio:1161077kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.098753%
size= 1173834kB time=21:02:15.50 bitrate= 127.0kbits/s speed= 642x
Converting mp4 to m4b...
converting output.mp4
Renaming output and cuesheet...
renaming output m4b and cuesheet...
Moving output and backing up cuesheet...
Make sure output looks good, input will be deleted
Press any key to continue . . .
[out#0/mp4 @ 000002463175a8c0] video:0kB audio:1208430kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.098777%
size= 1221708kB time=21:53:44.68 bitrate= 127.0kbits/s speed= 643x
Converting mp4 to m4b...
converting output.mp4
Renaming output and cuesheet...
renaming output m4b and cuesheet...
Moving output and backing up cuesheet...
Make sure output looks good, input will be deleted
Press any key to continue . . .

Windows and VLC show correct track lengths.

AudioAnchorite commented 3 months ago

So after further testing it would seem that the problem occurs on M4B that are beyond a certain length. I have re-processed a bunch of files from Audible and only the really lengthy ones are having the issue in iTunes.

AudioAnchorite commented 3 months ago

When I run the command ffmpeg -i export.m4b -f ffmetadata metadata.txt on export.m4b, I get this information at the end of the output:

  Stream #0:0[0x1](eng): Audio: aac (LC) (mp4a / 0x6134706D), 22050 Hz, stereo, fltp, 62 kb/s (default)
    Metadata:
      creation_time   : 2019-05-31T21:04:41.000000Z
      handler_name    : ?Apple Sound Media Handler
      vendor_id       : [0][0][0][0]
  Stream #0:1[0x2](eng): Data: bin_data (text / 0x74786574) (default)
    Metadata:
      creation_time   : 2019-05-31T21:04:41.000000Z
      handler_name    : ?Apple Text Media Handler
  Stream #0:2[0x0]: Video: mjpeg (Baseline), yuvj420p(pc, bt470bg/unknown/unknown), 2400x2400 [SAR 1:1 DAR 1:1], 90k tbr, 90k tbn (attached pic)
Unsupported codec with id 98314 for input stream 1
AudioAnchorite commented 3 months ago

After uninstalling and reinstalling this repo and all dependencies, I can confirm that I am still getting this error with M4B audiobooks that are longer than a certain runtime (somewhere between 11 hours and 20 hours).

AudioAnchorite commented 3 months ago

Also, what's really weird is that I redid the chapters on both of these files months ago without issue. I re-downloaded them from audible 2 days ago to polish the chapters a little more, and that's when the problem started.

I cannot imagine what in the world could have triggered this behaviour to start... I know it must have something to do with either ffmpeg or iTunes, but the only solution I can find is to transcode the files, which I am loath to do.

TheMetalCenter commented 3 months ago

Sorry I don't have time right now to do any serious testing, but I can comment on things to try. I don't think it is related to duration, as I have had no issues with audiobooks that are much longer (my longest m4b is 61 hours and has no issues).

If you add it to a different media metadata viewer like MusicBee or mp3tag do you see same incorrect duration?

I have had issues with number of chapters in the past, previously my limit was 255 if I remember correctly, but I do have a working m4b with 325. When I have time I want to examine why that one works when others didn't.

I don't think number of chapters would be an issue with Dune, so perhaps related to character limit? I remember Dune had pretty long chapter titles at the end.

Other idea is bitrate, do you know if it is a constant or variable bit rate?

I'd try messing with a working audiobook of similar length and seeing if you can replicate the error using Dune's cuesheet on that file.

AudioAnchorite commented 3 months ago

MediaInfo and Mp3tag show the proper information, as does the Windows File Properties window, and VLC Media Player. Only iTunes is displaying the glitch. Transcoding the file with dbPoweramp will solve the problem...

... Hold up! OK, so while typing this up, I was literally testing another hypothesis out, by downloading the AAX file for Unfinished Tales from Audible and then using InAudible's True Decrpyt to strip out the DRM (as opposed to using Libation--which is what I had been doing).

After InAudible finished, I took the M4B and ran it through your repo with a backed up cuesheet... Presto, a perfectly functioning M4B, with correct run time!

After repeating this procedure with Dune... yes, the file also works properly!

So, this is actually a very strange issue being caused by the interaction of a file, downloaded from Libation, with this repo's scripts. The file, if imported to iTunes directly from Libation's output, will not show a problem. Only when the chapters are processed using m4b_add-chapters.bat do I start to see the issue (I just tested both Libation files one more time after using InAudible--and can confirm that the issue was reproduced for the fifth time)!

I will post an issue on Libation's page to see if anyone knows what is going on. Perhaps ffmpeg was updated recently and Libation needs to be patched.

TheMetalCenter commented 3 months ago

Interesting. I also use Libation and have seen no issues, but I avoid iTunes like the plague so I haven't looked at that aspect.