Raheel Mushtaq
Raheel Mushtaq

Reputation: 35

creating video from selected images using FFMPEG through command Line Android

i am trying to make a video from selected images from command line using ffmpeg in android

using this project as my source i m trying to make video

this is the command i m trying to create video

   String[] ffmpegCommand = {ffmpegBin,
            "-y",
            "-qscale",
            "1",
            "-r", "" + frameRate,
            "-i", image1.getAbsolutePath(),
            "-t", "" + (((4) * 30) + 4), //"-s",heightwidth,
            "-i", image2.getAbsolutePath(),
            "-t", "" + (((4) * 30) + 4), //"-s",heightwidth,
            "-i", image3.getAbsolutePath(),
            "-t", "" + (((4) * 30) + 4), //"-s",heightwidth,
            "-i", image4.getAbsolutePath(),
            "-t", "" + (((4) * 30) + 4), //"-s",heightwidth,
            "-vcodec",
            "libx264",
            "-s",
            "640x480",
            outputFile.getAbsolutePath()};

but the video created shows only 1st image and video is created of less than a second

what is the problem in this statement ? and why only 1 image is shown in video?

sorry about my bad english

Upvotes: 2

Views: 6658

Answers (2)

Bhavin Patel
Bhavin Patel

Reputation: 76

Here i am creating video of 12 seconds from 4 images each of 3 seconds with fade in fade out effects.

Run below command and make sure that all the images having same height width.

String strCommand = "ffmpeg -loop 1 -t 3 -i " + /sdcard/videokit/1.jpg + " -loop 1 -t 3 -i " + /sdcard/videokit/2.jpg + " -loop 1 -t 3 -i " + /sdcard/videokit/3.jpg + " -loop 1 -t 3 -i " + /sdcard/videokit/4.jpg + " -filter_complex [0:v]trim=duration=3,fade=t=out:st=2.5:d=0.5[v0];[1:v]trim=duration=3,fade=t=in:st=0:d=0.5,fade=t=out:st=2.5:d=0.5[v1];[2:v]trim=duration=3,fade=t=in:st=0:d=0.5,fade=t=out:st=2.5:d=0.5[v2];[3:v]trim=duration=3,fade=t=in:st=0:d=0.5,fade=t=out:st=2.5:d=0.5[v3];[v0][v1][v2][v3]concat=n=4:v=1:a=0,format=yuv420p[v] -map [v] -preset ultrafast " + /sdcard/videolit/output.mp4;

Upvotes: 4

Gyan
Gyan

Reputation: 93018

This is the ffmpeg command that you should adapt into your string array:

ffmpeg -framerate 25 -t 124 -loop 1 -i image1
       -framerate 25 -t 124 -loop 1 -i image2
       -framerate 25 -t 124 -loop 1 -i image3
       -framerate 25 -t 124 -loop 1 -i image4
       -filter_complex "[0][1][2][3]concat=n=4"
       -c:v libx264 -s 640x480 outputfile

Rule is that input options (framerate, t..etc) go before the input entry.

The concat filter joins the image streams together. If they are different sizes, you should resize to make them the same.

Upvotes: 2

Related Questions