java 使用 ffmpeg 从图像创建视频文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10395136/
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
Create a Video file from images using ffmpeg
提问by Aashish Bhatnagar
I am able to compile and add ffmpeg to jni folder in my project created Android.mk file now I want to use ffmpeg to create a video file from the images I have stored in my static arraylist
我现在可以编译 ffmpeg 并将其添加到我的项目创建的 Android.mk 文件中的 jni 文件夹中,现在我想使用 ffmpeg 从我存储在静态数组列表中的图像创建视频文件
I have searched alot but couldn't find any tutorial any help is really appreciated.
我已经搜索了很多,但找不到任何教程,非常感谢任何帮助。
回答by mk..
I was in a similar need and accomplished the same. There are two ways in which you can do this. I would like to share the simpler one first.
我也有类似的需要并完成了同样的任务。有两种方法可以做到这一点。我想先分享一个更简单的。
Create a temporary folder inside the Android.
Copy your images in the new folder
First, rename your pictures to follow a numerical sequence. For example, img1.jpg, img2.jpg, img3.jpg,... Then you may run:
- Run this program programmetcally
ffmpeg -f image2 -i img%d.jpg /tmp/a.mpg
在 Android 内部创建一个临时文件夹。
将图像复制到新文件夹中
首先,重命名您的图片以遵循数字顺序。比如img1.jpg, img2.jpg, img3.jpg,... 那么你可以运行:
- 以编程方式运行此程序
ffmpeg -f image2 -i img%d.jpg /tmp/a.mpg
To run this programmatically,
要以编程方式运行,
Use the following code:
使用以下代码:
void convertImg_to_vid()
{
Process chperm;
try {
chperm=Runtime.getRuntime().exec("su");
DataOutputStream os =
new DataOutputStream(chperm.getOutputStream());
os.writeBytes("ffmpeg -f image2 -i img%d.jpg /tmp/a.mpg\n");
os.flush();
chperm.waitFor();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Get started with this. I will help you.. All the best
开始吧。我会帮助你..一切顺利
Use the tutorial : http://ffmpeg.org/faq.htmlSpecially gothrough 3.2 section inside the tutorial.
使用教程:http: //ffmpeg.org/faq.html 专门看教程里面的3.2部分。
To be able to run the above commands, you should have ffmpeg command in bin directory. The ffmpeg binary should be cross compiled for Android platform...
为了能够运行上述命令,你应该在 bin 目录中有 ffmpeg 命令。ffmpeg 二进制文件应该为 Android 平台交叉编译......