Java 中的视频缩略图
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/48179/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Video Thumbnails in Java
提问by Marcio Aguiar
I want to generate a thumbnail preview of videos in Java. I'm mostly JMF and video manipulation alienated.
我想用 Java 生成视频的缩略图预览。我主要是 JMF 和视频操作疏远。
- Is there an easy way to do it?
- What about codecs? Will I have to deal with it?
- Any video type is suported? (including Quicktime)
- 有没有简单的方法来做到这一点?
- 编解码器呢?我需要处理吗?
- 支持任何视频类型?(包括 Quicktime)
采纳答案by Joe Liversedge
There seems to be a few examples out there that are far better than what I was going to send you.
See http://krishnabhargav.blogspot.com/2008/02/processing-videos-in-java.html.
见http://krishnabhargav.blogspot.com/2008/02/processing-videos-in-java.html。
I'd agree with Stu, however. If you can find a way to get what you want using some command-line tools (and run them using Commons-Exec), you might have a better overall solution than depending on what is essentially the Sanskrit of Java extensions.
不过,我同意 Stu。如果您可以找到一种方法来使用一些命令行工具(并使用Commons-Exec运行它们)来获得您想要的东西,那么您可能有一个更好的整体解决方案,而不是依赖于本质上是 Java 扩展的梵文。
回答by Stu Thompson
Are you sure that JMF is right for you? Unfortunately, it is not in particularly good shape. Unless you are already committed to JMF, you very well may want to investigate alternatives. Wikipedia has a decent overview at en.wikipedia.org/wiki/Java_Media_Framework
您确定 JMF 适合您吗?不幸的是,它的状态不是特别好。除非您已经致力于 JMF,否则您很可能想研究替代方案。维基百科在en.wikipedia.org/wiki/Java_Media_Framework 上有一个不错的概述
Many JMF developers have complained that it supports few codecs and formats in modern use. Its all-Java version, for example, cannot play MPEG-2, MPEG-4, Windows Media, RealMedia, most QuickTime movies, Flash content newer than Flash 2, and needs a plug-in to play the ubiquitous MP3 format. While the performance packs offer the ability to use the native platform's media library, they're only offered for Linux, Solaris and Windows. Furthermore, Windows-based JMF developers can unwittingly think JMF provides support for more formats than it does, and be surprised when their application is unable to play those formats on other platforms.
Another knock against JMF is Sun's seeming abandonment of it. The API has not been touched since 1999, and the last news item on JMF's home page was posted in November 2004.
While JMF is built for extensibility, there are few such third-party extensions.
Furthermore, editing functionality in JMF is effectively non-existent, which makes a wide range of potential applications impractical.
许多 JMF 开发人员抱怨它在现代使用中支持的编解码器和格式很少。例如,它的全 Java 版本无法播放 MPEG-2、MPEG-4、Windows Media、RealMedia、大多数 QuickTime 电影、比 Flash 2 更新的 Flash 内容,并且需要插件才能播放无处不在的 MP3 格式。虽然性能包提供使用本机平台媒体库的能力,但它们仅适用于 Linux、Solaris 和 Windows。此外,基于 Windows 的 JMF 开发人员可能会在不知不觉中认为 JMF 提供的格式支持比它支持的格式更多,并且当他们的应用程序无法在其他平台上播放这些格式时感到惊讶。
对 JMF 的另一个打击是 Sun 似乎放弃了它。该API还没有被触及1999年,并在JMF的主页的最新消息项目被张贴在2004年11月。
虽然 JMF 是为可扩展性而构建的,但很少有这样的第三方扩展。
此外,JMF 中的编辑功能实际上是不存在的,这使得广泛的潜在应用程序变得不切实际。
回答by Stu Thompson
My own server-side app shells out to FFmpeg to do the encoding. I'm 98.42% sure FFmpeg does snapshots, too. (It is an all singing, all dancing beastof a program. The command line options alone could fill a book.)
我自己的服务器端应用程序使用 FFmpeg 进行编码。我 98.42% 肯定 FFmpeg 也做快照。(这是一个程序的所有唱歌,所有跳舞的野兽。仅命令行选项就可以填满一本书。)
Check it out: ffmpeg.mplayerhq.hu
回答by Art Clarke
Well, since you're not stuck with JMF, have you considered Xuggler? Xuggler is a Java API that uses FFmpeg under the covers to do all video decoding and encoding. It's free and LGPL licensed.
好吧,既然您没有坚持使用 JMF,那么您考虑过Xuggler吗?Xuggler 是一个 Java API,它在幕后使用 FFmpeg 来完成所有视频解码和编码。它是免费的,并获得 LGPL 许可。
In fact, we have a tutorial that shows How to Make Thumbnails of an Existing File
事实上,我们有一个教程展示了如何制作现有文件的缩略图
回答by kencoder
I tried Xuggler and JCodec; Both can generate the frame snapshot;
我尝试了 Xuggler 和 JCodec;两者都可以生成帧快照;
However, they cannot extract the orientation of the video properly (portrait video became landscape image); Anyone could help about this??
但是,他们无法正确提取视频的方向(纵向视频变成横向图像);任何人都可以帮助解决这个问题??
- JCodec: http://jcodec.org/
- Xuggler: http://www.javacodegeeks.com/2011/02/xuggler-tutorial-frames-capture-video.html
- JCodec:http://jcodec.org/
- Xuggler:http: //www.javacodegeeks.com/2011/02/xuggler-tutorial-frames-capture-video.html