Java 视频播放器

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/265160/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-29 11:42:06  来源:igfitidea点击:

Java Video Player

javavideobufferframecodec

提问by zakgof

I need a java api, that cannot use JMF, to play video interpreted by the SO codecs but i want to retrieve the each frames in java code. Somebody know some?

我需要一个不能使用 JMF 的 java api 来播放由 SO 编解码器解释的视频,但我想检索 java 代码中的每个帧。有人知道吗?

回答by Steve K

Have a look at FMJ. It does notrequire the Java Media Framework(JMF).

看看FMJ。它要求Java媒体框架(JMF)。

They have an exampleat the bottom of the page that writes out the first 5 frames of the video to files, so you should be able to get to the individual frames.

他们在页面底部有一个示例,将视频的前 5 帧写入文件,因此您应该能够访问各个帧。

回答by Paul Gregtheitroade

FMJ is very much out-of-date and JMF is a lost cause (yes one of those is IMHO). If you want something that works and will do exactly what you have described, try Xuggle. In their media tools examples they offer a simple player example using AWT / Swing. http://xuggle.com/

FMJ 已经过时了,而 JMF 是一个失败的原因(是的,恕我直言)。如果您想要一些有用的东西并且完全按照您的描述去做,请尝试 Xuggle。在他们的媒体工具示例中,他们提供了一个使用 AWT/Swing 的简单播放器示例。 http://xuggle.com/

回答by zakgof

If you're OK with Java wrapper around FFMpeg, try velvet-video.

如果您对 FFMpeg 周围的 Java 包装器没问题,请尝试velvet-video

Code snippet to extract images from a video file:

从视频文件中提取图像的代码片段:

IVelvetVideoLib lib = VelvetVideoLib().getInstance();
try (IDemuxer demuxer = lib.demuxer(new File("/some/path/example.mp4"))) {
    IDecoderVideoStream videoStream = demuxer.videoStream(0);
    IFrame videoFrame;
    while ((videoFrame = videoStream.nextFrame()) != null) {
        BufferedImage image = videoFrame.image();
        // Use image as needed...
    }
}    

A more advanced example of video player implementation using velvet-video can be found here.

可以在此处找到使用 velvet-video 实现视频播放器的更高级示例。

Disclaimer: I am the author of velvet-video.

免责声明:我是 velvet-video 的作者。