Java Xuggler元数据列表MP4/M4V视频



我正在尝试使用Xuggler,例如FFMPEG元数据包装器(我只需要MP4/M4V视频的章节列表(。

到目前为止,我还找不到解决方案。谁能帮我吗?

我只能获取以下信息:

    final String filename = "...path...";
    IContainer container = IContainer.make();
    int result = container.open(filename, IContainer.Type.READ, null);
    if (result < 0)
        throw new RuntimeException("Failed to open media file");
    int numStreams = container.getNumStreams();
    long duration = container.getDuration();
    long fileSize = container.getFileSize();
    long bitRate = container.getBitRate();
    System.out.println("Number of streams: " + numStreams);
    System.out.println("Duration (ms): " + duration);
    System.out.println("File Size (bytes): " + fileSize);
    System.out.println("Bit Rate: " + bitRate);
    for (int i = 0; i < numStreams; i++) {
        IStream stream = container.getStream(i);
        IStreamCoder coder = stream.getStreamCoder();
        System.out.println("*** Start of Stream Info ***");
        System.out.printf("stream %d: ", i);
        System.out.printf("type: %s; ", coder.getCodecType());
        System.out.printf("codec: %s; ", coder.getCodecID());
        System.out.printf("duration: %s; ", stream.getDuration());
        System.out.printf("start time: %s; ", container.getStartTime());
        System.out.printf("timebase: %d/%d; ", stream.getTimeBase().getNumerator(),
                stream.getTimeBase().getDenominator());
        System.out.printf("coder tb: %d/%d; ", coder.getTimeBase().getNumerator(),
                coder.getTimeBase().getDenominator());
        System.out.println();
        if (coder.getCodecType() == ICodec.Type.CODEC_TYPE_AUDIO) {
            System.out.printf("sample rate: %d; ", coder.getSampleRate());
            System.out.printf("channels: %d; ", coder.getChannels());
            System.out.printf("format: %s", coder.getSampleFormat());
        } else if (coder.getCodecType() == ICodec.Type.CODEC_TYPE_VIDEO) {
            System.out.printf("width: %d; ", coder.getWidth());
            System.out.printf("height: %d; ", coder.getHeight());
            System.out.printf("format: %s; ", coder.getPixelType());
            System.out.printf("frame-rate: %5.2f; ", coder.getFrameRate().getDouble());
        }
        System.out.println();
        System.out.println("*** End of Stream Info ***");

更新07.06.2017 我只是用VLCJ尝试了一下,但我仍然无法获得章节列表。

    File file = new File("ia_ISL_13_r720P.m4v");
    NativeLibrary.addSearchPath(RuntimeUtil.getLibVlcLibraryName(), "vlc64/");
    Native.loadLibrary(RuntimeUtil.getLibVlcLibraryName(), LibVlc.class);
    MediaPlayerFactory mpf = new MediaPlayerFactory();
    EmbeddedMediaPlayer emp = mpf.newEmbeddedMediaPlayer();
    MediaMeta mediaMeta = mpf.getMediaMeta(file.getAbsolutePath(), true);
    MediaMetaData asMediaMetaData = mediaMeta.asMediaMetaData();
    System.out.println(asMediaMetaData.getAlbum());
    System.out.println(asMediaMetaData.getArtist());
    System.out.println(asMediaMetaData.getTitle());
    emp.prepareMedia(file.getAbsolutePath());
    emp.play();
    emp.nextChapter(); // -> GO NEXT CHAPTER - SUCCESS
    List<List<String>> allChapterDescriptions = emp.getAllChapterDescriptions();
    for (List<String> list : allChapterDescriptions) {
        for (String string : list) {
            System.out.println(string);
        }
    }

您是否测试过MP4章?适用于.NET,但是开源的,也许会有所帮助。

正在在C#项目中使用它,我猜与您正在做的事情类似,非常相似...在这里,正在使用MP4和M4V章节喂食列表箱,其中旧的MP4和M4V文件的缝隙正常工作,但是与New的MP4和M4V文件相关(2014->(

using Mp4Chapters;
// more code here...
private void readChapters(string inputFull)
{
            using (var str = File.OpenRead(this.inputFull))
            {
                var extractor = new ChapterExtractor(new StreamWrapper(str));
                extractor.Run();
                // build the listbox
                foreach (var c in extractor.Chapters ?? new ChapterInfo[0])
                {
                    this.lb_chapters.Items.Add(new { chapterTime = c.Time, chapterName = c.Name });
                }
            }
}

其他选项是使用ffmpeg解析视频文件并阅读结果:

ffmpeg -i ia_isl_13_r720p.m4v -f ffmetadata metadata.txt

我希望这会有所帮助,让我知道。(对不起,英语不是我的主要语言(

最新更新