I'm Facing current porblem. I have an Array of 100 Bitmaps. these are Screenshots i took from a view. I used JCodec to make it to a video, buts its waay to slow. Im hoping to get better results with FFmpeg
Now i want to use the FFmpeg Library. Simillar questions were asked but i have no Idea how to use ffmpeg and how i have to use it in my specific case. All i see are weird Complex Commands See:
File dir = your directory where image stores;
String filePrefix = "picture"; //imagename prefix
String fileExtn = ".jpg";//image extention
filePath = dir.getAbsolutePath();
File src = new File(dir, filePrefix + "%03d" + fileExtn);// image name should ne picture001, picture002,picture003 soon ffmpeg takes as input valid
complexCommand = new String[]{"-i", src + "", "-c:v", "libx264", "-c:a", "aac", "-vf", "setpts=2*PTS", "-pix_fmt", "yuv420p", "-crf", "10", "-r", "15", "-shortest", "-y", "/storage/emulated/0/" + app_name + "/Video/" + app_name + "_Video" + number + ".mp4"};
The Problem is, that in this case he is using a Path. I need it to be from an Array. And i have no idea what to do with the String (ComplexCommands) :/ My Bitmaps are like this:
Bitmap[] bitmaps = new Bitmaps[100];
this is filled later on.
if anyone is searching on how to do it with JCodec:
try {
out = NIOUtils.writableFileChannel( Environment.getExternalStorageDirectory().getAbsolutePath()+"/***yourpath***/output"+System.currentTimeMillis()+".mp4");
// for Android use: AndroidSequenceEncoder
AndroidSequenceEncoder encoder = new AndroidSequenceEncoder(out, Rational.R(25, 1));
for (int i = 0 ; i < 100 ; i++) {
// Generate the image, for Android use Bitmap
// Encode the image
System.out.println("LOO2P"+i);
encoder.encodeImage(bitmaps[i]);
}
// Finalize the encoding, i.e. clear the buffers, write the header, etc.
encoder.finish();
} catch (FileNotFoundException e) {
System.out.println("fNF");
e.printStackTrace();
} catch (IOException e) {
System.out.println("IOE");
e.printStackTrace();
} finally {
System.out.println("IOSSE");
NIOUtils.closeQuietly(out);
}