如何从Android中的图像数组创建视频? [英] How to create a video from an array of images in Android?

查看:100
本文介绍了如何从Android中的图像数组创建视频?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想调用一个函数并从图像列表中构建一个视频,然后将其保存在本地设备上:

I want to call a function and build a video out of list of images, and then save it locally on the device:

public void CreateAndSaveVideoFile(List<Bitmap> MyBitmapArray)
{
   // ..
}

试用:

  • Following java/xuggle - encode array of images into a movie, the link in the answer is a dead link

关注如何通过编程将图像编码为Java视频文件?,接受答案中建议的库不支持Android。

Following How to encode images into a video file in Java through programming?, The suggested library in the accepted answer does not support Android.

上面的下一个答案有针对Android用户的方法,但我不清楚该功能的输入和输出(他在哪里做了)图像?他在哪里收到视频?) - 我留下了一个问题评论

The next answer in the above has an approach for Android users however it is not clear for me the input and the output of that function (where did he give the images? and where did he get the video?) - I left a question comment

上面的下一个答案提供了一个完整的类,但是需要的库是包含有一个损坏的文件(当我尝试从提供的链接下载它时) - 我留下了一个问题评论

The next answer in the above provides a whole class, however the required library to be included has a corrupted file (when I try and download it from the provided link) - I left a question comment

关注Java:如何从一组图像创建电影?,顶部答案中建议的库使用我不熟悉的命令,我甚至不知道如何使用它们。喜欢:

Following Java: How do I create a movie from an array of images?, the suggested library in the top answer uses commands that I am not familiar with and I don't even know how to use them. Like:


从当前所有JPEG文件创建MPEG-4文件
目录:

Creating an MPEG-4 file from all the JPEG files in the current directory:

mencoder mf://*.jpg -mf w = 800:h = 600:fps = 25:type = jpg -ovc lavc \
-lavcopts vcodec = mpeg4:mbd = 2:trell -oac copy -o output.avi

我不知道如何在Java / Android项目中使用上述内容..

I don't know how can I use the above in a Java / Android project..

任何人都可以帮助指导我或/并为我提供了解决我任务的方法?在此先感谢。

Can anyone help in guiding me or/and providing me with an approach to my task? Thanks in advance.

推荐答案

您可以使用jcodec SequenceEncoder 来转换序列图像到MP4文件。

You can use jcodec SequenceEncoder to convert sequence of images to MP4 file.

示例代码:

import org.jcodec.api.awt.SequenceEncoder;
...
SequenceEncoder enc = new SequenceEncoder(new File("filename"));
// GOP size will be supported in 0.2
// enc.getEncoder().setKeyInterval(25);
for(...) {
    BufferedImage image = ... // Obtain an image to encode
    enc.encodeImage(image);
}
enc.finish();

这是一个java库,所以很容易将它导入到Android项目中,你不必使用NDK与ffmpeg不同。

It's a java library so it's easy to import it into Android project, you don't have to use NDK unlike ffmpeg.

请参阅 http://jcodec.org/代码示例&下载。

Refer http://jcodec.org/ for sample code & downloads.

这篇关于如何从Android中的图像数组创建视频?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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