Create a Video file from images using ffmpeg(使用 ffmpeg 从图像创建视频文件)
问题描述
我现在可以在我的项目创建的 Android.mk 文件中编译并将 ffmpeg 添加到 jni 文件夹中我想使用 ffmpeg 从我存储在我的静态数组列表中的图像创建一个视频文件
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
我搜索了很多,但找不到任何教程,非常感谢任何帮助.
I have searched alot but couldn't find any tutorial any help is really appreciated.
推荐答案
我有类似的需求并完成了同样的工作.有两种方法可以做到这一点.我想先分享一个简单的.
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.
在 Android 中创建一个临时文件夹.
Create a temporary folder inside the Android.
将图片复制到新文件夹中
Copy your images in the new folder
首先,按照数字顺序重命名您的图片.比如img1.jpg,img2.jpg,img3.jpg,... 那么你可以运行:
First, rename your pictures to follow a numerical sequence. For example, img1.jpg, img2.jpg, img3.jpg,... Then you may run:
要以编程方式运行,
使用以下代码:
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
");
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
使用教程:http://ffmpeg.org/faq.html 里面专门通读了3.2部分教程.
Use the tutorial : http://ffmpeg.org/faq.html Specially gothrough 3.2 section inside the tutorial.
为了能够运行上述命令,你应该在 bin 目录中有 ffmpeg 命令.ffmpeg 二进制文件应该针对 Android 平台进行交叉编译...
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...
这篇关于使用 ffmpeg 从图像创建视频文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:使用 ffmpeg 从图像创建视频文件
基础教程推荐
- Maven:无效的目标版本:10 2022-01-01
- 将 Windows 证书导入 Java 2022-01-01
- doFilter()是在servlet的工作完成之前还是之后执行的? 2022-01-01
- 在springboot中如何给mybatis加拦截器 2023-04-29
- 控制台应用程序中的 Java 键盘输入解析 2022-01-01
- Java ECDSAwithSHA256 签名长度不一致 2022-01-01
- 如何在相机中应用自定义滤镜 [Surfaceview 预览]. 2022-01-01
- JPA惰性列表上的流 2022-01-01
- 将 double 转换为 Int,向下舍入 2022-01-01
- 在java中使用xpath和selenium解析HTML表格数据 2022-01-01
