1
votes

I am trying to read chapters from mp4 video files. I don't see this in the File.Tags list, but I was hoping there was a way to get them via requesting the chap atom.

I did try mp4chap, but it only gets me the first chapter. I think it may be meant for audio files only.

1

1 Answers

0
votes

I am the author of mp4chap lib.

Yes, you are correct. mp4chap library is meant to use for audio files only.

Library is open source and really simple, you are free to modify it.

Here library analyze only first track (see code below). You can play with this code and get more data from mp4 tracks.

http://mp4chap.codeplex.com/SourceControl/latest#Mp4Chapters/ChapterExtractor.cs

    private void ReadChapters(MoovInfo moovBox)
    {
        var soundBox = moovBox.Tracks.Where(b => b.Type == "soun").ToArray();
        if (soundBox.Length == 0) return;
        if (soundBox[0].Chaps != null && soundBox[0].Chaps.Length > 0)
        {
            var cb = new HashSet<uint>(soundBox[0].Chaps);
            var textBox = moovBox.Tracks.Where(b => b.Type == "text" && cb.Contains(b.Id)).ToArray();
            if (textBox.Length == 0) return;
            ReadChaptersText(textBox[0]);
        }
    }