patrickenfuego / Chapterize-Audiobooks

Split a single, monolithic mp3 audiobook file into chapters using Machine Learning and ffmpeg.
Apache License 2.0
95 stars 16 forks source link

Inconsitent support for mp4a #18

Open eaglexboy opened 9 months ago

eaglexboy commented 9 months ago

I love that the script can detect and splice a big file into chapters but it would be nice it also supported mp4a encoding consistently. The script is able to analyze and generate SRT file from mp4a but it cannot splice the file. It would be nice if the script could detect that the source was encoded using mp4a and automatically convert it to a temporary mp3 file so it can splice it or let the user know before it starts to process it that the encoding is not supported.

I manually converted the file mp4a file to mp3 to confirm that the error reported was due to it being mp4 and not for another reason and it worked as expected.

ffmpeg_log.txtx

[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55e69758ce40] Discarding ID3 tags because more suitable tags were found.
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/mnt/Podcast/Vaughn_Heppner/Star_Raider/Star_Raider.mp3':
  Metadata:
    major_brand     : dash
    minor_version   : 0
    compatible_brands: iso6mp41
    creation_time   : 2023-11-20T06:27:35.000000Z
  Duration: 12:18:42.06, start: 0.000000, bitrate: 129 kb/s
  Stream #0:0(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 127 kb/s (default)
    Metadata:
      creation_time   : 2023-11-20T06:27:35.000000Z
      handler_name    : ISO Media file produced by Google Inc.
      vendor_id       : [0][0][0][0]
Input #1, image2, from '/mnt/Podcast/Vaughn_Heppner/Star_Raider/star_raider.jpg':
  Duration: 00:00:00.04, start: 0.000000, bitrate: 14626 kb/s
  Stream #1:0: Video: mjpeg (Progressive), yuvj444p(pc, bt470bg/unknown/unknown), 362x342 [SAR 300:300 DAR 181:171], 25 fps, 25 tbr, 25 tbn, 25 tbc
[mp3 @ 0x55e6975e6680] Invalid audio stream. Exactly one MP3 audio stream is required.
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
Error initializing output stream 0:1 -- 
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #1:0 -> #0:1 (copy)
    Last message repeated 1 times
----------------------------------------------------

********************************************************
NEW LOG START
********************************************************

[mov,mp4,m4a,3gp,3g2,mj2 @ 0x5641cafe2e80] Discarding ID3 tags because more suitable tags were found.
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/mnt/Podcast/Vaughn_Heppner/Star_Raider/Star_Raider.mp3':
  Metadata:
    major_brand     : dash
    minor_version   : 0
    compatible_brands: iso6mp41
    creation_time   : 2023-11-20T06:27:35.000000Z
  Duration: 12:18:42.06, start: 0.000000, bitrate: 129 kb/s
  Stream #0:0(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 127 kb/s (default)
    Metadata:
      creation_time   : 2023-11-20T06:27:35.000000Z
      handler_name    : ISO Media file produced by Google Inc.
      vendor_id       : [0][0][0][0]
Input #1, image2, from '/mnt/Podcast/Vaughn_Heppner/Star_Raider/star_raider.jpg':
  Duration: 00:00:00.04, start: 0.000000, bitrate: 14626 kb/s
  Stream #1:0: Video: mjpeg (Progressive), yuvj444p(pc, bt470bg/unknown/unknown), 362x342 [SAR 300:300 DAR 181:171], 25 fps, 25 tbr, 25 tbn, 25 tbc
[mp3 @ 0x5641cb03c180] Invalid audio stream. Exactly one MP3 audio stream is required.
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
Error initializing output stream 0:1 -- 
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #1:0 -> #0:1 (copy)
    Last message repeated 1 times
----------------------------------------------------

[mov,mp4,m4a,3gp,3g2,mj2 @ 0x556de9d23e80] Discarding ID3 tags because more suitable tags were found.
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/mnt/Podcast/Vaughn_Heppner/Star_Raider/Star_Raider.mp3':
  Metadata:
    major_brand     : dash
    minor_version   : 0
    compatible_brands: iso6mp41
    creation_time   : 2023-11-20T06:27:35.000000Z
  Duration: 12:18:42.06, start: 0.000000, bitrate: 129 kb/s
  Stream #0:0(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 127 kb/s (default)
    Metadata:
      creation_time   : 2023-11-20T06:27:35.000000Z
      handler_name    : ISO Media file produced by Google Inc.
      vendor_id       : [0][0][0][0]
Input #1, image2, from '/mnt/Podcast/Vaughn_Heppner/Star_Raider/star_raider.jpg':
  Duration: 00:00:00.04, start: 0.000000, bitrate: 14626 kb/s
  Stream #1:0: Video: mjpeg (Progressive), yuvj444p(pc, bt470bg/unknown/unknown), 362x342 [SAR 300:300 DAR 181:171], 25 fps, 25 tbr, 25 tbn, 25 tbc
[mp3 @ 0x556de9d7d180] Invalid audio stream. Exactly one MP3 audio stream is required.
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
Error initializing output stream 0:1 -- 
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #1:0 -> #0:1 (copy)
    Last message repeated 1 times
----------------------------------------------------
...
patrickenfuego commented 8 months ago

thank you for your feedback - Yes you are correct, in its current form it only supports MP3 files (as that was the original intent). For now, convert them to mp3 using -c copy file.mp3 in ffmpeg (or whatever tool) as a workaround.

However, I am in the middle of a massive overhaul to the app and I will gladly add m4a processing as well - one of the big new features coming is adding m4b conversion support, so I can slide in m4a support as well.