的Java Xuggler元数据列表M4V视频

问题描述:

我试图用Xuggler像FFmpeg的元数据封装(我只需要/ M4V视频MP4的章节列表)。的Java Xuggler元数据列表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 ***"); 

UPDATE 2017年6月7日 我只是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); 
     } 
    } 
+0

任何人都可以帮你什么? 什么是你的代码确切的问题?例外? 请澄清一下您的问题! –

+0

我写了:(我只是需要/ M4V视频MP4的章节列表)。该代码不包含错误。无论如何,我更新了这个帖子。 – MrSax

+0

更新07.06.2017 – MrSax

你测试了Mp4Chapters?是为.NET,但是是开源的,也许帮助。我想你在做什么类似的,非常相似... 这里是喂mp4和m4v章节的列表框,与旧的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

我希望这有助于让 我知道。 (抱歉的英语,是不是我的主要语言)