2

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.

4

1 回答 1

0

我是 mp4chap lib 的作者。

是的,你是对的。mp4chap 库仅用于音频文件。

库是开源的,非常简单,您可以自由修改它。

这里库只分析第一首曲目(见下面的代码)。您可以使用此代码并从 mp4 曲目中获取更多数据。

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]);
        }
    }
于 2015-12-29T17:05:37.933 回答