如何从各种视频文件格式中提取元数据? [英] How can I extract meta data from various video file formats?

查看:2616
本文介绍了如何从各种视频文件格式中提取元数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从各种视频文件格式中提取元数据,尤其是分辨率和使用的编解码器类型。 (还有像作者这样的所有其他东西)。我无法为此找到一个库。

How can I extract meta data from various video file formats, especially the Resolution and the type of codec used. (But also all other stuff like author). I was not able to find a library for that.

推荐答案

我找到了 MediaInfo ,提供有关视频或音频文件的大量技术和标签信息。

I have found MediaInfo, which supplies dozens of technical and tag information about a video or audio file.

有一个我认为非常有用的 subs4me的源代码树中的MediaInfo的JNI包装器。

There is a JNI wrapper for MediaInfo in subs4me's source tree that I find very useful.

以下是一些代码片段,展示了如何从媒体文件中提取一些信息:

Here are some code snippets that show how to extract some information from a media file:

File file         = new File("path/to/my/file");
MediaInfo info    = new MediaInfo();

info.open(file);

String format     = info.get(MediaInfo.StreamKind.Video, i, "Format", 
                             MediaInfo.InfoKind.Text,
                             MediaInfo.InfoKind.Name);

int bitRate       = info.get(MediaInfo.StreamKind.Video, i, "BitRate", 
                             MediaInfo.InfoKind.Text,
                             MediaInfo.InfoKind.Name);

float frameRate   = info.get(MediaInfo.StreamKind.Video, i, "FrameRate", 
                             MediaInfo.InfoKind.Text, 
                             MediaInfo.InfoKind.Name);

short width       = info.get(MediaInfo.StreamKind.Video, i, "Width", 
                             MediaInfo.InfoKind.Text, 
                             MediaInfo.InfoKind.Name);

int audioBitrate  = info.get(MediaInfo.StreamKind.Audio, i, "BitRate", 
                             MediaInfo.InfoKind.Text, 
                             MediaInfo.InfoKind.Name);

int audioChannels = info.get(MediaInfo.StreamKind.Audio, i, "Channels", 
                             MediaInfo.InfoKind.Text, 
                             MediaInfo.InfoKind.Name);

这篇关于如何从各种视频文件格式中提取元数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆