[Enhancement]: Read ASIN and CDEK tags from m4b (maybe more?) files #1608

Open
opened 2026-04-24 23:51:30 +02:00 by adam · 0 comments
Owner

Originally created by @johnpyp on GitHub (Dec 22, 2023).

Describe the feature/enhancement

As far as I can tell, currently the audiobook server only uses ffprobe for metadata fetching from audio files. This is somewhat limiting, at least in the case of m4b, because it only grabs metadata fields that are either well-defined standard fields, or use the standard namespace-prefix scheme.

However, many audiobook files have extra fields to store some of this metadata that don't follow the standard scheme, and of particular interest are the non-standard ASIN and CDEK fields. CDEK is the field that is most faithful to the AAX file format, and so is included in many 1:1 copies.

Because we can't get to these extra fields currently, another library would likely have to be introduced.

  • tone is already used and can pickup these extra fields, which would work well, but I see there's some interest in removing it as a dependency in the first place. Reportedly it also has some trouble with some m4b files
  • mediainfo.js is a pure-js emscripten compilation of the widely used and popular mediainfo library, which would fit nicely in this codebase. It also supports extracting these custom fields, and seems to work great for all the files I've tested it on so far.

An example of using mediainfo js on one of my audiobook files, mediainfo.js The\ Will\ of\ the\ Many/The\ Will\ of\ the\ Many.m4b -f JSON.

{
  "creatingLibrary": {
    "name": "MediaInfoLib",
    "version": "23.07",
    "url": "https://mediaarea.net/MediaInfo"
  },
  "media": {
    "@ref": "",
    "track": [
      {
        "@type": "General",
        "AudioCount": "1",
        "MenuCount": "1",
        "Format": "MPEG-4",
        "Format_Profile": "Base Media",
        "CodecID": "isom",
        "CodecID_Compatible": "iso2/mp41/M4A /M4B ",
        "FileSize": "809187505",
        "Duration": "101681.072",
        "OverallBitRate_Mode": "VBR",
        "OverallBitRate": "63665",
        "StreamSize": "11065587",
        "HeaderSize": "32",
        "DataSize": "798125517",
        "FooterSize": "11061956",
        "IsStreamable": "No",
        "Title": "The Will of the Many",
        "Title_More": "At the elite Catenan Academy, a young fugitive uncovers layered mysteries and world-changing secrets in this new fantasy series by internationally best-selling author of the Licanius Trilogy James Islington.\\nAudi. Vide. Tace.\\nThe Catenan Republic—the Hierarchy—may rule the world now, but they do not know everything.\\nI tell them my name is Vis Telimus. I tell them I was orphaned after a tragic accident three years ago, and that good fortune alone has led to my acceptance into their most prestigious school. I tell them that once I graduate, I will gladly join the rest of civilized society in allowing my strength, my drive, and my focus—what they call Will—to be leeched away and added to the power of those above me, as millions already do. As all must eventually do.\\nI tell them that I belong, and they believe me.\\nBut the truth is that I have been sent to the Academy to find answers. To solve a murder. To search for an ancient weapon. To uncover secrets that may tear the Republic apart.\\nAnd that I will never, ever cede my Will to the empire that executed my family.\\nTo survive, though, I will still have to rise through the Academy’s ranks. I will have to smile, and make friends, and pretend to be one of them and win. Because if I cannot, then those who want to control me, who know my real name, will no longer have any use for me.\\nAnd if the Hierarchy finds out who I truly am, they will kill me.",
        "Album": "The Will of the Many",
        "Album_Performer": "James Islington",
        "Track": "The Will of the Many",
        "Track_More": "At the elite Catenan Academy, a young fugitive uncovers layered mysteries and world-changing secrets in this new fantasy series by internationally best-selling author of the Licanius Trilogy James Islington.\\nAudi. Vide. Tace.\\nThe Catenan Republic—the Hierarchy—may rule the world now, but they do not know everything.\\nI tell them my name is Vis Telimus. I tell them I was orphaned after a tragic accident three years ago, and that good fortune alone has led to my acceptance into their most prestigious school. I tell them that once I graduate, I will gladly join the rest of civilized society in allowing my strength, my drive, and my focus—what they call Will—to be leeched away and added to the power of those above me, as millions already do. As all must eventually do.\\nI tell them that I belong, and they believe me.\\nBut the truth is that I have been sent to the Academy to find answers. To solve a murder. To search for an ancient weapon. To uncover secrets that may tear the Republic apart.\\nAnd that I will never, ever cede my Will to the empire that executed my family.\\nTo survive, though, I will still have to rise through the Academy’s ranks. I will have to smile, and make friends, and pretend to be one of them and win. Because if I cannot, then those who want to control me, who know my real name, will no longer have any use for me.\\nAnd if the Hierarchy finds out who I truly am, they will kill me.",
        "Track_Position": "1",
        "Grouping": "Hierarchy",
        "Performer": "James Islington",
        "Composer": "Euan Morton",
        "Recorded_Date": "2023-05-23",
        "Encoded_Date": "2023-05-16 02:12:58 UTC",
        "Tagged_Date": "2023-05-23 11:13:44 UTC",
        "Encoded_Library": "Apple QuickTime",
        "Encoded_Library_Name": "Apple QuickTime",
        "BPM": "64",
        "Copyright": "©2023 James Islington ℗2023 Audible, Inc.",
        "Cover": "Yes",
        "Comment": "Unabridged",
        "extra": {
          "prID": "BK_ADBL_054581JP",
          "pub": "Audible Studios",
          "nrt": "Euan Morton",
          "CDEK": "B0BXTXBVK9",
          "CDET": "ADBL",
          "VERS": "48144921",
          "AACR": "CR!54A800JFMN4F7DET55N4WFAD6GC2",
          "_sti": "The Will of the Many (Unabridged)",
          "rldt": "23-May-2023",
          "TCOM": "Euan Morton",
          "publisher": "Audible Studios",
          "Original_Date": "2023-05-23",
          "Original_Year": "2023"
        }
      },
      {
        "@type": "Audio",
        "StreamOrder": "0",
        "ID": "1",
        "Format": "AAC",
        "Format_AdditionalFeatures": "LC",
        "CodecID": "2 / 40 / mp4a-40-2",
        "Duration": "101681.063",
        "BitRate_Mode": "VBR",
        "BitRate": "62794",
        "BitRate_Maximum": "69431",
        "Channels": "2",
        "ChannelPositions": "Front: L R",
        "ChannelLayout": "L R",
        "SamplesPerFrame": "1024",
        "SamplingRate": "22050",
        "SamplingCount": "2242067439",
        "FrameRate": "21.533",
        "FrameCount": "2189519",
        "Compression_Mode": "Lossy",
        "StreamSize": "798121918",
        "Language": "en",
        "Encoded_Date": "2023-05-16 02:12:58 UTC",
        "Tagged_Date": "2023-05-23 11:13:44 UTC",
        "extra": {
          "Menus": "2"
        }
      },
      {
        "@type": "Menu",
        "StreamOrder": "1",
        "ID": "2",
        "Format": "Timed Text",
        "CodecID": "text",
        "Duration": "101681.072",
        "Language": "en",
        "extra": {
          "Encoded_Date": "2023-05-16 02:12:58 UTC",
          "Tagged_Date": "2023-05-16 02:12:58 UTC",
          "Menu_For": "1",
          "Source_Duration": "101681032",
          "Source_FrameCount": "79",
          "Source_StreamSize": "3583",
          "FrameCount": "79",
          "StreamSize": "3583",
          "mdhd_Duration": "101681064"
        }
      }
    ]
  }
}
Originally created by @johnpyp on GitHub (Dec 22, 2023). ### Describe the feature/enhancement As far as I can tell, currently the audiobook server only uses ffprobe for metadata fetching from audio files. This is somewhat limiting, at least in the case of m4b, because it only grabs metadata fields that are either well-defined standard fields, or use the standard namespace-prefix scheme. However, many audiobook files have extra fields to store some of this metadata that don't follow the standard scheme, and of particular interest are the non-standard `ASIN` and `CDEK` fields. CDEK is the field that is most faithful to the AAX file format, and so is included in many 1:1 copies. Because we can't get to these extra fields currently, another library would likely have to be introduced. - `tone` is already used and can pickup these extra fields, which would work well, but I see there's some interest in removing it as a dependency in the first place. Reportedly it also has some trouble with some m4b files - [mediainfo.js](https://github.com/buzz/mediainfo.js) is a pure-js emscripten compilation of the widely used and popular `mediainfo` library, which would fit nicely in this codebase. It also supports extracting these custom fields, and seems to work great for all the files I've tested it on so far. An example of using mediainfo js on one of my audiobook files, `mediainfo.js The\ Will\ of\ the\ Many/The\ Will\ of\ the\ Many.m4b -f JSON`. ```json { "creatingLibrary": { "name": "MediaInfoLib", "version": "23.07", "url": "https://mediaarea.net/MediaInfo" }, "media": { "@ref": "", "track": [ { "@type": "General", "AudioCount": "1", "MenuCount": "1", "Format": "MPEG-4", "Format_Profile": "Base Media", "CodecID": "isom", "CodecID_Compatible": "iso2/mp41/M4A /M4B ", "FileSize": "809187505", "Duration": "101681.072", "OverallBitRate_Mode": "VBR", "OverallBitRate": "63665", "StreamSize": "11065587", "HeaderSize": "32", "DataSize": "798125517", "FooterSize": "11061956", "IsStreamable": "No", "Title": "The Will of the Many", "Title_More": "At the elite Catenan Academy, a young fugitive uncovers layered mysteries and world-changing secrets in this new fantasy series by internationally best-selling author of the Licanius Trilogy James Islington.\\nAudi. Vide. Tace.\\nThe Catenan Republic—the Hierarchy—may rule the world now, but they do not know everything.\\nI tell them my name is Vis Telimus. I tell them I was orphaned after a tragic accident three years ago, and that good fortune alone has led to my acceptance into their most prestigious school. I tell them that once I graduate, I will gladly join the rest of civilized society in allowing my strength, my drive, and my focus—what they call Will—to be leeched away and added to the power of those above me, as millions already do. As all must eventually do.\\nI tell them that I belong, and they believe me.\\nBut the truth is that I have been sent to the Academy to find answers. To solve a murder. To search for an ancient weapon. To uncover secrets that may tear the Republic apart.\\nAnd that I will never, ever cede my Will to the empire that executed my family.\\nTo survive, though, I will still have to rise through the Academy’s ranks. I will have to smile, and make friends, and pretend to be one of them and win. Because if I cannot, then those who want to control me, who know my real name, will no longer have any use for me.\\nAnd if the Hierarchy finds out who I truly am, they will kill me.", "Album": "The Will of the Many", "Album_Performer": "James Islington", "Track": "The Will of the Many", "Track_More": "At the elite Catenan Academy, a young fugitive uncovers layered mysteries and world-changing secrets in this new fantasy series by internationally best-selling author of the Licanius Trilogy James Islington.\\nAudi. Vide. Tace.\\nThe Catenan Republic—the Hierarchy—may rule the world now, but they do not know everything.\\nI tell them my name is Vis Telimus. I tell them I was orphaned after a tragic accident three years ago, and that good fortune alone has led to my acceptance into their most prestigious school. I tell them that once I graduate, I will gladly join the rest of civilized society in allowing my strength, my drive, and my focus—what they call Will—to be leeched away and added to the power of those above me, as millions already do. As all must eventually do.\\nI tell them that I belong, and they believe me.\\nBut the truth is that I have been sent to the Academy to find answers. To solve a murder. To search for an ancient weapon. To uncover secrets that may tear the Republic apart.\\nAnd that I will never, ever cede my Will to the empire that executed my family.\\nTo survive, though, I will still have to rise through the Academy’s ranks. I will have to smile, and make friends, and pretend to be one of them and win. Because if I cannot, then those who want to control me, who know my real name, will no longer have any use for me.\\nAnd if the Hierarchy finds out who I truly am, they will kill me.", "Track_Position": "1", "Grouping": "Hierarchy", "Performer": "James Islington", "Composer": "Euan Morton", "Recorded_Date": "2023-05-23", "Encoded_Date": "2023-05-16 02:12:58 UTC", "Tagged_Date": "2023-05-23 11:13:44 UTC", "Encoded_Library": "Apple QuickTime", "Encoded_Library_Name": "Apple QuickTime", "BPM": "64", "Copyright": "©2023 James Islington ℗2023 Audible, Inc.", "Cover": "Yes", "Comment": "Unabridged", "extra": { "prID": "BK_ADBL_054581JP", "pub": "Audible Studios", "nrt": "Euan Morton", "CDEK": "B0BXTXBVK9", "CDET": "ADBL", "VERS": "48144921", "AACR": "CR!54A800JFMN4F7DET55N4WFAD6GC2", "_sti": "The Will of the Many (Unabridged)", "rldt": "23-May-2023", "TCOM": "Euan Morton", "publisher": "Audible Studios", "Original_Date": "2023-05-23", "Original_Year": "2023" } }, { "@type": "Audio", "StreamOrder": "0", "ID": "1", "Format": "AAC", "Format_AdditionalFeatures": "LC", "CodecID": "2 / 40 / mp4a-40-2", "Duration": "101681.063", "BitRate_Mode": "VBR", "BitRate": "62794", "BitRate_Maximum": "69431", "Channels": "2", "ChannelPositions": "Front: L R", "ChannelLayout": "L R", "SamplesPerFrame": "1024", "SamplingRate": "22050", "SamplingCount": "2242067439", "FrameRate": "21.533", "FrameCount": "2189519", "Compression_Mode": "Lossy", "StreamSize": "798121918", "Language": "en", "Encoded_Date": "2023-05-16 02:12:58 UTC", "Tagged_Date": "2023-05-23 11:13:44 UTC", "extra": { "Menus": "2" } }, { "@type": "Menu", "StreamOrder": "1", "ID": "2", "Format": "Timed Text", "CodecID": "text", "Duration": "101681.072", "Language": "en", "extra": { "Encoded_Date": "2023-05-16 02:12:58 UTC", "Tagged_Date": "2023-05-16 02:12:58 UTC", "Menu_For": "1", "Source_Duration": "101681032", "Source_FrameCount": "79", "Source_StreamSize": "3583", "FrameCount": "79", "StreamSize": "3583", "mdhd_Duration": "101681064" } } ] } } ```
adam added the enhancement label 2026-04-24 23:51:30 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/audiobookshelf#1608