如何在 Java 中编辑 MP4 ID3 标签?

发布于 2024-11-08 07:50:05 字数 852 浏览 0 评论 0原文

我前一段时间问过类似的问题,但是用的是Python,从那时起我决定切换到Java,因为似乎有更多的资源可以做这类事情。基本上,我需要某种库、想法或说明,让我能够在 MP4 文件中编辑 ID3 标签,就像在 iTunes 中找到的那样。如果有人知道任何事情,我们将不胜感激您的帮助。

到目前为止,我已经完成了以下操作:

  1. 我发现了一个非常相似问题的问题/答案:How do you Edit Video ID3v2 Tags in Java(它描述了如何使用一个名为 JID3 的音频文件库来编辑视频 ID3 标签),但我可以'我一生都没有弄清楚如何将它实际导入到 Eclipse 项目中并使用它。我基本上将它解压并将所有包添加到项目中,但它工作一次后就使电影文件无法被任何媒体播放器读取。如果有人对如何导入和使用 JID3 有具体的了解,那就太好了。

  2. 我找到了这个网站:http://willcode4beer.com/parsing.jsp? set=mp3ID3 其中有一些看似不错的代码用于读取和写入 ID3 标签,不幸的是它无法正常工作,不断返回问号字符串或告诉我该文件不自发存在(它实际上会工作一次并且然后在没有任何更改的情况下再次工作)。不过,我喜欢简单地读取文件的字节或 ASCII 并以这种方式查找/编辑 ID3 标记的想法,因此如果有人知道该怎么做,那就太棒了。

提前致谢。

I asked a similar question some time ago, but with python, and have since then decided to switch to Java because there seemed to be more resources to do this sort of thing. Basically I need some sort of library, idea, or instructions that would allow me to edit ID3 tags in an MP4 file like the kind found in iTunes. If anyone knows anything, your help would be greatly appreciated.

So far I've done the following:

  1. I've found this question/answer to a very similar problem: How do you Edit Video ID3v2 Tags in Java (it describes how to use a library intended for audio files called JID3 to edit video ID3 tags), but I can't figure out for the life of me how to actually import it into an eclipse project and use it. I basically unpacked it and added all the packages into the project, but the one time it worked it made the movie file unreadable to any media player afterwards. If anyone has specific knowledge of how to import and use JID3 that would be great.

  2. I've found this site: http://willcode4beer.com/parsing.jsp?set=mp3ID3 which has some seemingly good code for reading and writing ID3 tags, unfortunately it does not work properly constantly returning strings of question marks or telling me that the file is not there spontaneously (it will literally work one time and then not work another time without any changes). Nevertheless I like the idea of simply reading the bytes or ASCII of a file and finding/editing the ID3 tag that way so if anyone knows what to do for that, that'd be awesome.

Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

拥醉 2024-11-15 07:50:06

MP4中的元数据不一定是ID3格式。有可能使用 ID3,但尚未广泛使用。 ID3 字节随后位于 /moov/meta/id32 框中。
iTunes 文件在 /moov/udta/... 中有多个框,如“@cmt”、“@nam”、“@des”、“@cpy”,其中每个框包含一个字符串(在本例中) ) 评论、名称、描述、版权。查看 http://code.google.com/p/mp4parser/ 进行可视化、解析并写入MP4文件。

The metadata in MP4 is not necessarily in ID3 format. There is the possibility to use ID3 but it is not widely used. The ID3 bytes are then in /moov/meta/id32 box.
The iTunes files bear their meta information in /moov/udta/... there are multiple boxes like '@cmt', '@nam', '@des', '@cpy' that contain each a string for (in this case) comment, name, description, copyright. Have a look at http://code.google.com/p/mp4parser/ to visualize, parse and write MP4 files.

不念旧人 2024-11-15 07:50:06

如果我理解正确的话,您希望能够编辑元数据,例如:艺术家、曲目、封面图像等,然后能够在 iTunes 或 QuickTime 中看到您的更改。

在这种情况下,您可能需要查看 JCodec 中可用的新 API (org.jcodec.movtool.MetadataEditor)。
它还有一个 CLI ( org.jcodec.movtool.MetadataEditorMain)。

这是基本用法:

# Changes the author of the movie
./metaedit -f -si ©ART=New\ value file.mov

或者通过 Java API 进行相同的操作:

MetadataEditor mediaMeta = MetadataEditor.createFrom(new
    File("file.mp4"));
Map<Integer, MetaValue> meta = mediaMeta.getItunesMeta();
meta.put(0xa9415254, MetaValue.createString("New value")); // fourcc for '©ART'
mediaMeta.save(false); // fast mode is off

您可以在这里找到完整的文档:http: //jcodec.org/docs/working_with_mp4_metadata.html

If I understand you correctly you want to be able to edit such metadata as: artist, track, cover image etc. and then be able to see your changes in iTunes or QuickTime.

In that case you may want to look at the new API available in JCodec (org.jcodec.movtool.MetadataEditor).
It also has a CLI (org.jcodec.movtool.MetadataEditorMain).

Here's the basic usage:

# Changes the author of the movie
./metaedit -f -si ©ART=New\ value file.mov

or the same thing via the Java API:

MetadataEditor mediaMeta = MetadataEditor.createFrom(new
    File("file.mp4"));
Map<Integer, MetaValue> meta = mediaMeta.getItunesMeta();
meta.put(0xa9415254, MetaValue.createString("New value")); // fourcc for '©ART'
mediaMeta.save(false); // fast mode is off

You can find a complete documentation here: http://jcodec.org/docs/working_with_mp4_metadata.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文