bhuvnesh123 / FFmpeg-Video-Editor-Android

Sample android project using ffmpeg for cutting and compressing video,reversing video,extracting image frames from video,extracting audio from video,add fade in fade out effect,create fast and slow motion video
540 stars 165 forks source link

Select images and convert them to a video #30

Closed soujanyamandala closed 4 years ago

soujanyamandala commented 4 years ago

I tried few commands to make a video with multiple images but no luck with those and in this project there is no option to make a video with images. Can someone guide me with this?

bhuvnesh123 commented 4 years ago

Use below command to create video from images placed in same folder

String command[]={"-y", "-r","1/5" ,"-i",src.getAbsolutePath(), "-c:v","libx264","-vf", "fps=25","-pix_fmt","yuv420p", dest.getAbsolutePath()};

Here ,

src.getAbsolutePath() is the absolute path of all your input images.

For example, If all your images are stored in Images folder inside Pictures directory with names extract_picture001.jpg,extract_picture002.jpg,extract_picture003.jpg……

. Then,

String filePrefix = "extract_picture";
String fileExtn = ".jpg";
File picDir = Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_PICTURES);
File dir = new File(picDir, "Images");
File src = new File(dir, filePrefix + "%03d" + fileExtn);

For creating video from images placed in different folder you have to create a text file and add image paths to it and then specify the path of that text file as an input option. Example,

Text File

file '/storage/emulated/0/DCIM/Camera/P_20170807_143916.jpg'
duration 2
file '/storage/emulated/0/DCIM/Pic/P_20170305_142948.jpg'
duration 5
file '/storage/emulated/0/DCIM/Camera/P_20170305_142939.jpg'
duration 6
file '/storage/emulated/0/DCIM/Pic/P_20170305_142818.jpg'
duration 2

Command

String command[] = {"-y", "-f", "concat", "-safe", "0", "-i", textFile.getAbsolutePath(), "-vsync", "vfr", "-pix_fmt", "yuv420p", dest.getAbsolutePath()};

where textFile.getAbsolutePath() is the absolute path of your text file