简体   繁体   中英

Create a Video file from images using 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.

  • 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

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.html Specially gothrough 3.2 section inside the tutorial.

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...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM