Use "jcodec": need to download jcodec, import its project, and add it as library project
/** make video file with images (software encoding)
*
* @param images
* the images
* @param location
* the path
* @param name
* the video file name
* @return the path of video file
*/
public String softwareMakeVideo(ArrayList<File> images, String location,
String name)
{
File directory = new File(location);
if(!directory.exists())
{
directory.mkdir();
}
File file = new File(directory, name + ".mp4");
try
{
SequenceEncoder encoder = new SequenceEncoder(file);
for (Iterator<File> iterator = images.iterator(); iterator
.hasNext();)
{
File image = (File) iterator.next();
if (!image.exists() || image.length() == 0)
{
continue;
}
Bitmap frame = BitmapFactory
.decodeFile(image.getAbsolutePath());
try
{
encoder.encodeImage(frame);
} catch (Exception e)
{
e.printStackTrace();
}
}
encoder.finish();
} catch (IOException e)
{
e.printStackTrace();
}
return file.getAbsolutePath();
}
Weakness: slow because it use software encoding