将一系列图像编码为视频
如何在 Android 上从一系列图像/照片创建视频文件? 现在的SDK可以实现吗?或者我需要一个编解码器库?
How can I create a video file from a series of images/photos on Android?
Can this be done with the current SDK? or do I need a codec library?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我同意马克的观点。 C/C++ 库包括 ffmpeg 此处 或 X264 此处。我不得不说我还没有发现它们或 Android NDK 易于使用,但这可能是因为我对 C/C++ 和 JNI 不太了解。如果您对此路线感兴趣,那么适用于 Android 的 RockPlayer 免费应用程序具有来自 ffmpeg 的预构建共享库,可供在 Android 上使用。他们声称这些库仅使用 LGPL 组件,但我想您必须对此感到满意。对于 Java,有一个 ffmpeg 端口(某种),毫不奇怪地称为 jffmpeg,您可以在 此处 但它仍然调用现有的 ffmpeg 框架的大部分内容,因此您又回到了 NDK 领域。可以使用 Java Media Framework (JMF) 将一系列图像转换为视频,但它具有以下缺点:
我见过的另一个选项是 Adobe Air,但它的有效负载为 17Mb,一些用户对此有所抱怨。
Stack Overflow 上还有很多有关 ffmpeg 和 Android NDK 的其他问题。
祝项目顺利。
I agree with Mark. Among the C/C++ libraries are ffmpeg here or X264 here. I have to say I havn't found them or the Android NDK easy to use but that's probably because I don't really know much about C/C++ and JNI. If you're interested in this route, then the RockPlayer free app for Android has the pre-built shared libraries from ffmpeg ready for use on Android. They claim these libraries only use LGPL components but you'd have to satisfy yourself on this, I guess. With regards to Java, there is a port (of sorts) of ffmpeg called, unsurprisingly, jffmpeg which you can access here but it still calls out to much of the existing ffmpeg framework, so you're back in NDK land. It is possible to convert a series of images to video with the Java Media Framework (JMF) but it has the following drawbacks:
Another option I've seen used is Adobe Air, but it's a 17Mb payload which some users complain about.
There are lots of other questions here on Stack Overflow regarding ffmpeg and Android NDK.
Good luck with the project.
对此没有内置支持。您需要找到一些可以满足您需要的 Java 源代码,或者一些可以转换为库并通过 NDK 使用的 C/C++ 代码。或者,如果最终目标是将视频存储在服务器上,请上传图像/照片并让服务器创建视频。
There is no built-in support for this. You would need to either find some Java source code that does what you need, or some C/C++ code you can turn into a library and use via the NDK. Or, if the end goal is for the video to be on a server, upload the images/photos and have the server create the video.
ffmpeg
是您的救援护林员。您可以下载适用于 Android 的 FFMPEG 端口。请参阅问题Android 上的 FFmpeg 了解更多详细信息。该端口支持几乎所有您需要的内容,包括格式 - 输入图像格式为 GIF、JPG、PNG、BMP 等,输出视频格式为 AVI、MP4(容器)以及多种编解码器。
ffmpeg
is your rescue ranger. You can download the FFMPEG port for android. Refer to the question FFmpeg on Android for more details.The port supports almost everything that you'll ever need, including the formats - input image formats being GIF, JPG, PNG, BMP etc and output video formats being AVI, MP4 (containers) with a lot of codecs.
您可以使用名为 JCodec ( http://jcodec.org ) 的免费开源库,其中包含一些流行的纯 Java 实现视频格式和编解码器,包括:H.264 ( AVC )、MPEG 1/2、Apple ProRes、JPEG、MP4 ( ISO BMF )、MPEG PS、MPEG TS、Matroska。
您可以使用下面利用 JCodec 低级 API 的 CORRECTED 类:
You can use a free open source library called JCodec ( http://jcodec.org ) that contains pure java implementations of some popular video formats and codecs, including: H.264 ( AVC ), MPEG 1/2, Apple ProRes, JPEG, MP4 ( ISO BMF ), MPEG PS, MPEG TS, Matroska.
You can use the CORRECTED class below that utilizes JCodec low-level API: