用于检查视频元数据的Java库(如果是1080p,720p等) [英] Java library to check a video's metadata (if it's 1080p, 720p, etc)

查看:379
本文介绍了用于检查视频元数据的Java库(如果是1080p,720p等)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一个查看视频元数据的库,看看视频是1080p,720p还是最不能获得基本元数据(分辨率,比特率等),这样我就可以进行计算来检查我自己。

I'm currently looking for a library that looks at a videos metadata and see if the video is 1080p, 720p or a least be able get the basic metadata(resolution, bitrate, etc) so I could do the calculations to check myself.

我希望图书馆体积小,跨平台,它可以支持多种主要格式。有点像 https://github.com/drewnoakes/metadata-extractor ,当然还有视频。

I'm hoping the library is light in size, cross platform and it can support a number of the main formats. Something like https://github.com/drewnoakes/metadata-extractor but of course for videos.

我试着四处寻找,什么都没找到,这样的库存在吗?

I tried searching around and found nothing, does such a library exist?

推荐答案

我还没有尝试过,但似乎 Java MP4 Parser 库是我的意思一直在寻找。它能够读取和编辑元数据,跨平台,并且文件大小似乎很轻。

I haven't tried it yet, but seems Java MP4 Parser library is what I've been looking for. It is able to read and edit metadata, cross platform and seems to be light in file size.

github文档的摘录:

An excerpt from the github documentation:


Java MP4 Parser



用于读取,写入和创建MP4容器的Java API。操作
容器与编码和解码视频和音频不同。
使用库

Java MP4 Parser

A Java API to read, write and create MP4 container. Manipulating containers is different from encoding and decoding videos and audio. Using the library

该库已发布到Maven存储库。每个版本都按
推送到发布页面上发布的暂存存储库。在
请求中,特定版本可以推送到maven central。

The library is published to Maven repositories. Each release is pushed to a staging repository which is published on the release page. On request specific releases can be pushed to maven central.

  <dependency>
    <groupId>com.googlecode.mp4parser</groupId>
    <artifactId>isoparser</artifactId>
    <version>1.1.7</version>
  </dependency>

对于不使用依赖关系管理工具的项目,每个
版本的工件(jar,javadoc) -jar,source-jar)附加到
发布页面。请注意,该项目需要
aspectj-rt.jar库。

For projects that do not use a dependency management tool each release's artifacts (jar, javadoc-jar, source-jar) are attached to the release page. Please be aware that the project requires the aspectj-rt.jar library.

MP4 Parser的典型任务是:

Typical tasks for the MP4 Parser are:


  • 将音频/视频复用到MP4文件中

  • 附加使用相同编码设置的录制文件

  • 添加/更改元数据

  • 通过省略框架缩短录制内容我的示例将全部使用H264和AAC作为这两个编解码器是MP4文件最典型的。 AC-3是
    也并不罕见,因为编解码器在DVD上是众所周知的。还有带有H263 / MPEG-2视频轨道的
    MP4文件,但它们不再像大多数Android手机一样被广泛使用。您还可以

  • Muxing audio/video into an MP4 file
  • Append recordings that use same encode settings
  • Adding/Changing metadata
  • Shorten recordings by omitting frames My examples will all use H264 and AAC as these two codecs are most typical for MP4 files. AC-3 is also not uncommon as the codec is well known from DVD. There are also MP4 files with H263/MPEG-2 video tracks but they are no longer used widespread as most android phones. You can also

API和流程是直截了当的:

The API and the process is straight-forward:

您将每个原始格式文件包装到适当的Track对象中。

You wrap each raw format file into an appropriate Track object.


H264TrackImpl h264Track = new H264TrackImpl(new
FileDataSourceImpl(video.h264)); AACTrackImpl aacTrack = new
AACTrackImpl(new FileDataSourceImpl(audio.aac));

H264TrackImpl h264Track = new H264TrackImpl(new FileDataSourceImpl("video.h264")); AACTrackImpl aacTrack = new AACTrackImpl(new FileDataSourceImpl("audio.aac"));

然后添加这些Track对象到电影对象

These Track object are then added to a Movie object

Movie movie = new Movie();
movie.addTrack(h264Track);
movie.addTrack(aacTrack);

将Movie对象输入MP4Builder以创建容器。

The Movie object is fed into an MP4Builder to create the container.

Container mp4file = new DefaultMp4Builder().build(movie);

将容器写入适当的水槽。

Write the container to an appropriate sink.

FileChannel fc = new FileOutputStream(new
File(output.mp4))。getChannel(); mp4file.writeContainer(FC);
fc.close();有些情况下帧速率是从
波段发出信号或事先已知,因此H264不包含
。在这种情况下,您必须将它提供给构造函数。

FileChannel fc = new FileOutputStream(new File("output.mp4")).getChannel(); mp4file.writeContainer(fc); fc.close(); There are cases where the frame rate is signalled out of band or is known in advance so that the H264 doesn't contain it literally. In this case you will have to supply it to the constructor.

以下格式有Track实现:

There are Track implementations for the following formats:


  • H264

  • AAC

  • AC3

  • EC3

  • H264
  • AAC
  • AC3
  • EC3

另外还有两个不直接换行原始
格式的字幕轨道,但它们在概念上相似。

and additionally two subtitle tracks that do not directly wrap a raw format but they are conceptually similar.

音频和视频不同步。每当有
时间问题时,请确保开始

Audio and video are not in sync. Whenever there are problems with timing possible make sure to start

In AAC总是采样/ 1024样本/秒,因此每个样本的
持续时间为1000 * 1024 / samplerate毫秒。

In AAC there are always samplerate/1024 sample/s so each sample's duration is 1000 * 1024 / samplerate milliseconds.


  • 48KHz = > ~21.3ms

  • 44.1KHz => ~23.2ms

通过省略样本开始你可以轻松缩短音频
曲目。尽可能多地删除。你将无法将音频
和视频完全匹配,但人类对早期音频的感知比晚期音频更明智

By omitting samples from the start you can easily shorten the audio track. Remove as many as you need. You will not be able to match audio and video exactly with that but the human perception is more sensible to early audio than to late audio.

记住:如果有人距离只有10米,那么音频
和视频之间的延迟时间> 30ms。大脑习惯了!

Remember: If someone is only 10 meters away the delay between audio and video is >30ms. The brain is used to that!

AACTrackImpl aacTrackOriginal = new AACTrackImpl(new
FileDataSourceImpl(audio.aac)); //删除第一个样本,
缩短AAC轨道约22ms CroppedTrack aacTrackShort = new
CroppedTrack(aacTrackOriginal,1,aacTrack.getSamples()。size());

AACTrackImpl aacTrackOriginal = new AACTrackImpl(new FileDataSourceImpl("audio.aac")); // removes the first sample and shortens the AAC track by ~22ms CroppedTrack aacTrackShort = new CroppedTrack(aacTrackOriginal, 1, aacTrack.getSamples().size());

重要的是要强调你不能追加任何两个曲目

It is important to emphasize that you cannot append any two tracks with:


  • 不同的分辨率

  • 不同的帧率

从电影中创建JPEG。不 - 这不是解码器。 MP4 Parser
不知道该怎么做。从JPEG创建电影

Create JPEGs from a movie. No - this is no decoder. The MP4 Parser doesn't know how to do that. Create a movie from JPEGs

这篇关于用于检查视频元数据的Java库(如果是1080p,720p等)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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