Bug 451787 - Edit chapters in MP4/AAC files
Summary: Edit chapters in MP4/AAC files
Status: RESOLVED FIXED
Alias: None
Product: kid3
Classification: Applications
Component: general (show other bugs)
Version: 3.9.x
Platform: Other All
: NOR wishlist
Target Milestone: ---
Assignee: Urs Fleisch
URL:
Keywords:
: 450652 (view as bug list)
Depends on:
Blocks:
 
Reported: 2022-03-22 08:06 UTC by Lee
Modified: 2022-06-04 04:53 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
attachment-16104-0.html (1.48 KB, text/html)
2022-05-11 04:24 UTC, Lee
Details
attachment-3274-0.html (999 bytes, text/html)
2022-06-03 05:26 UTC, Lee
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Lee 2022-03-22 08:06:13 UTC
MP4/AAC files can contain chapter marks with chapter text, it would be great if this data could be editable as well as the chapter times.
Comment 1 Urs Fleisch 2022-03-24 19:57:57 UTC
This seems to be a rather obscure/unofficial corner in the MP4 world. I saw http://forum.doom9.org/showthread.php?p=1608021 and http://forum.doom9.org/showthread.php?p=1569412 but I am still confused and not sure which atoms are needed to implement such a feature (if it really can be realized using metadata atoms and not some other mechanism inside the MP4 file). Do you have further technical information or even a specification? Do you have instructions on how to create an example file with such information in it?

Anyway, if this requires new atom types, such a feature request would have to go first to TagLib or mp4v2, which are the libraries used by Kid3 to tag MP4 files.
Comment 2 Lee 2022-04-04 08:27:13 UTC
the app openaudible creates m4b files with such chapters so can other apps

I have lots of them, but they are all from audible....
Comment 3 Lee 2022-04-04 08:34:15 UTC
so does this app https://github.com/KrumpetPirate/AAXtoMP3 which might be easier to follow
Comment 4 Lee 2022-04-07 02:18:06 UTC
*** Bug 450652 has been marked as a duplicate of this bug. ***
Comment 5 Lee 2022-04-07 02:23:46 UTC
i can provide a sample file if i can get some guidance on what content in the file would be desired
Comment 6 Lee 2022-04-22 01:49:10 UTC
here is a project that creates such files.... https://github.com/KrumpetPirate/AAXtoMP3/blob/master/AAXtoMP3
Comment 7 Lee 2022-04-22 03:28:40 UTC
(In reply to Lee from comment #6)
> here is a project that creates such files....
> https://github.com/KrumpetPirate/AAXtoMP3/blob/master/AAXtoMP3

this creates mp3 or m4b files depending on the options set when running
Comment 8 Lee 2022-05-04 23:05:44 UTC
(In reply to Urs Fleisch from comment #1)
> This seems to be a rather obscure/unofficial corner in the MP4 world. I saw
> http://forum.doom9.org/showthread.php?p=1608021 and
> http://forum.doom9.org/showthread.php?p=1569412 but I am still confused and
> not sure which atoms are needed to implement such a feature (if it really
> can be realized using metadata atoms and not some other mechanism inside the
> MP4 file). Do you have further technical information or even a
> specification? Do you have instructions on how to create an example file
> with such information in it?
> 
> Anyway, if this requires new atom types, such a feature request would have
> to go first to TagLib or mp4v2, which are the libraries used by Kid3 to tag
> MP4 files.

https://mp4v2.org/api/struct_m_p4_chapter__s.html#details looks to be related to chapter details.....
Comment 9 Urs Fleisch 2022-05-08 05:05:04 UTC
Thanks for the additional information. The thing with mp4v2 could be used with Kid3's Mp4v2Metadata plugin. Could you please provide some example files containing such chapter information?
Comment 10 Lee 2022-05-09 04:39:03 UTC
(In reply to Urs Fleisch from comment #9)
> Thanks for the additional information. The thing with mp4v2 could be used
> with Kid3's Mp4v2Metadata plugin. Could you please provide some example
> files containing such chapter information?

i don't know how to create an example file other than using openaudible, and all of these are copyrighted....
i have asked if they can send me such a file....alternatively you can use the application to create your own if you have an audible account

or you can try to create such a file with https://github.com/KrumpetPirate/AAXtoMP3/blob/master/AAXtoMP3 and tell it to generate m4b files
Comment 11 Urs Fleisch 2022-05-10 18:54:02 UTC
I now have found m4b files containing chapters which can be read with libmp4v2. It returns a list of duration/title pairs and they seem to contain the same information which can be displayed using mediainfo. mediainfo shows a bit more information, but probably these list of durations and titles should be sufficient. libmp4v2 can read QuickTime and Nero formats, but the files I found have only QuickTime chapters, so I suppose supporting this type should be enough.
Comment 12 Lee 2022-05-11 04:24:17 UTC
Created attachment 148722 [details]
attachment-16104-0.html

The m4b files I have also have duration title pars and these title (chapter
names) can be seen in vlc  though the Playback > Chapter menu both in the
latest release her and the vet 3 beta

On Wed, 11 May 2022, 4:54 am Urs Fleisch, <bugzilla_noreply@kde.org> wrote:

> https://bugs.kde.org/show_bug.cgi?id=451787
>
> --- Comment #11 from Urs Fleisch <ufleisch@users.sourceforge.net> ---
> I now have found m4b files containing chapters which can be read with
> libmp4v2.
> It returns a list of duration/title pairs and they seem to contain the same
> information which can be displayed using mediainfo. mediainfo shows a bit
> more
> information, but probably these list of durations and titles should be
> sufficient. libmp4v2 can read QuickTime and Nero formats, but the files I
> found
> have only QuickTime chapters, so I suppose supporting this type should be
> enough.
>
> --
> You are receiving this mail because:
> You reported the bug.
Comment 13 Urs Fleisch 2022-05-23 16:15:49 UTC
You can find kid3-git20220523 in https://sourceforge.net/projects/kid3/files/kid3/development/, where I have implemented support for chapters in MP4 files. First make sure that you have activated the Mp4v2Metadata plugin and that it is above the TaglibMetadata plugin. Restart Kid3 if a plugin change was needed.

You can then find the chapters of MP4 files in a "Chapters" frame. I have reused the same dialog as for the synchronized lyrics in MP3 files, so you can play the file and have the chapters displayed in a (slow) Karaoke-like fashion. With the context menu, you can directly seek to the position of a chapter and you can add chapter timestamps while the file is playing or add them manually and enter the time with the keyboard.
Comment 14 Lee 2022-05-26 05:19:51 UTC
(In reply to Urs Fleisch from comment #13)
> You can find kid3-git20220523 in
> https://sourceforge.net/projects/kid3/files/kid3/development/, where I have
> implemented support for chapters in MP4 files. First make sure that you have
> activated the Mp4v2Metadata plugin and that it is above the TaglibMetadata
> plugin. Restart Kid3 if a plugin change was needed.
> 
> You can then find the chapters of MP4 files in a "Chapters" frame. I have
> reused the same dialog as for the synchronized lyrics in MP3 files, so you
> can play the file and have the chapters displayed in a (slow) Karaoke-like
> fashion. With the context menu, you can directly seek to the position of a
> chapter and you can add chapter timestamps while the file is playing or add
> them manually and enter the time with the keyboard.

I installed the version from git, I checked the plugin is enabled correctly, and am not seeing the chapters frame, the m4b file has 20 chapters in it....created with OpenAudible
Comment 15 Urs Fleisch 2022-05-27 09:07:57 UTC
> I installed the version from git, I checked the plugin is enabled correctly, and am not seeing the chapters frame, the m4b file has 20 chapters in it....created with OpenAudible

Strange, I just verified it with the Linux and Windows packages of version git20220523 and both show the Chapters for the two Audible files I have, so please verify the following

* Which platform are you using, Linux, Windows, Mac?
* Is "Mp4v2Metadata" checked in the "Plugins" tab of the settings and above "TaglibMetadata" (otherwise TagLib is used for MP4)?
* If you open an MP4 file and then click the "Add..." button in the "Tag 2" section, in the list of the "Select the frame ID" dialog, is there a "Chapters" entry between "Category" and "Comment"?
  - yes: You are using the latest Kid3 snapshot with Mp4v2Metadata. With this entry, you would be able to add your own list of chapters (do this only on a copy of a file since it will delete existing chapters).
  - no: In the list of entries in the "Select the frame ID" dialog, is there an entry "Show Work & Movement"?
    + yes: You are using "TaglibMetadata" for MP4 files, please check your plugin settings.
    + no: You are using "Mp4v2Metadata", but probably not in version "git20220523".

Where do you end in the decision tree ("- yes", "+ yes" or "+ no")?
Comment 16 Urs Fleisch 2022-05-29 16:34:00 UTC
I have converted an aax file to m4b using AAXtoMP3 and the chapters are editable in Kid3.
Comment 17 Lee 2022-05-30 06:43:31 UTC
Which platform are you using, Linux, Windows, Mac? Mac Catalina
Is "Mp4v2Metadata" checked in the "Plugins" tab of the settings and above
"TaglibMetadata" (otherwise TagLib is used for MP4)? yes
Id3libMetadata is 1st
OggFlacMetadata is 2nd
"Mp4v2Metadata" is 3rd
"TaglibMetadata" is 4th
all checked

* If you open an MP4 file and then click the "Add..." button in the "Tag 2"
section, in the list of the "Select the frame ID" dialog, is there a "Chapters"
entry between "Category" and "Comment"? YES
  - yes: You are using the latest Kid3 snapshot with Mp4v2Metadata. With this
entry, you would be able to add your own list of chapters (do this only on a
copy of a file since it will delete existing chapters).

the file already has chapters, I can see the chapters using VLC, I can't see them, however in kid3...
 
this is where I get, I am trying to see existing chapters in the m4b file...
Comment 18 Lee 2022-05-30 06:49:32 UTC
the Chapters entry in the metadata exists but it is blank
Comment 19 Lee 2022-05-30 07:00:00 UTC
(In reply to Lee from comment #18)
> the Chapters entry in the metadata exists but it is blank

oh, you need to click the edit button to see chapters :D I see them now
timestamp format = Milliseconds as unit
Content Type = Other
Description = [blank]
then there is Lyrics 
and then the list of chapters

I need to do more testing but it looks like the last chapter is the end of the book?
i think this because it is an extra chapter at the end that has no text....
Comment 20 Lee 2022-06-03 03:34:30 UTC
when playing the m4b file within the app, would the currently playing chapter name be shown?
Comment 21 Urs Fleisch 2022-06-03 04:51:21 UTC
> when playing the m4b file within the app, would the currently playing chapter name be shown?

You have to open the "Chapters" dialog (by clicking on "Edit") to see the currently playing chapter highlighted.
Comment 22 Lee 2022-06-03 05:26:17 UTC
Created attachment 149426 [details]
attachment-3274-0.html

thank you :)

On Fri, 3 Jun 2022 at 14:51, Urs Fleisch <bugzilla_noreply@kde.org> wrote:

> https://bugs.kde.org/show_bug.cgi?id=451787
>
> --- Comment #21 from Urs Fleisch <ufleisch@users.sourceforge.net> ---
> > when playing the m4b file within the app, would the currently playing
> chapter name be shown?
>
> You have to open the "Chapters" dialog (by clicking on "Edit") to see the
> currently playing chapter highlighted.
>
> --
> You are receiving this mail because:
> You reported the bug.
Comment 23 Urs Fleisch 2022-06-04 04:53:14 UTC
Git commit cdcbae4321d1ff1c19c0023821046600b04316cc by Urs Fleisch.
Committed on 04/06/2022 at 04:51.
Pushed by ufleisch into branch 'master'.

Mp4v2Metadata: Support chapters in MP4 files

M  +17   -0    doc/en/index.docbook
M  +6    -3    src/core/model/kid3application.cpp
M  +1    -0    src/core/tags/frame.cpp
M  +2    -1    src/gui/dialogs/editframefieldsdialog.cpp
M  +214  -41   src/plugins/mp4v2metadata/m4afile.cpp
M  +1    -1    src/plugins/mp4v2metadata/m4afile.h

https://invent.kde.org/multimedia/kid3/commit/cdcbae4321d1ff1c19c0023821046600b04316cc