使用 ffmpeg 从图像创建视频文件 [英] Create a Video file from images using ffmpeg

查看:40
本文介绍了使用 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 从图像创建视频文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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