gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 23:26:34 24 4
gpt4 key购买 nike

我正在尝试使用像 FFMPEG Metadata Wrapper 这样的 Xuggler(我只需要 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);
}
}

最佳答案

你测试过 Mp4Chapters 吗?适用于 .net,但它是开源的,可能会有所帮助。

我在一个 C# 项目中使用它,我猜这与你正在做的类似,非常相似......
这是一个带有 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

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

关于Java Xuggler 元数据章节列表 MP4/M4V 视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44392032/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com