have a buffer which has the Mats from which i want to create a video
I transform those mats into byte array and write them to the outputstream yet for some reason whenever I watch the video only one image is shown heres the code
try {
File sdCard = Environment.getExternalStorageDirectory();
File dir = new File (sdCard.getAbsolutePath() + "/ran");
dir.mkdirs();
File file = new File(dir, "goal_ran.mp4");
FileOutputStream out = new FileOutputStream(file);
for(int i=0;i<buffer.size();i++)
{
Mat mat = buffer.get(i);
MatOfByte matOfByte = new MatOfByte();
Imgcodecs.imencode(".png", mat, matOfByte);
byte[] byteArray = matOfByte.toArray();
out.write(byteArray);
out.flush();
/*byte[] return_buff = new byte[(int) (buffer.get(i).total() * buffer.get(i).elemSize())];
buffer.get(i).get(0, 0, return_buff);*/
/*int length = (int) (mat.total() * mat.elemSize());
byte buffer[] = new byte[length];
mat.get(0, 0, buffer);
out.write(buffer);*/
}
out.close();
Log.d("Video","Successful"+ buffer.size());
} catch (Exception e) {
e.printStackTrace();
}