I am selecting a list of images from my SD card and the selected images as to view in a video format for the user. I don't know what to do is any idea or link to refer. Please help me. Thanks in advance.
Asked
Active
Viewed 327 times
2 Answers
2
@Harini- please follow up this link or you can try below code
try {
File file = this.getFullPath("", "video.mp4");
SequenceEncoder encoder = new SequenceEncoder(file);
// only 5 frames in total
for (int i = 1; i <= 5; i++) {
// getting bitmap from drawable path
int bitmapResId = this.getResources().getIdentifier("image" + i, "drawable", this.getPackageName());
Bitmap bitmap = this.getBitmapFromResources(this.getResources(), bitmapResId);
encoder.encodeNativeFrame(this.pictureFromBitmap(bitmap));
}
encoder.finish();
} catch (IOException e) {
e.printStackTrace();
}
// get full SD path
File getFullPath(String filePatho, String fileName) {
File extBaseDir = Environment.getExternalStorageDirectory();
if (filePatho == null || filePatho.length() == 0 || filePatho.charAt(0) != '/') filePatho = "/" + filePatho;
makeDirectory(filePatho);
File file = new File(extBaseDir.getAbsoluteFile() + filePatho);
return new File(file.getAbsolutePath() + "/" + fileName); // file;
}
// convert from Bitmap to Picture (jcodec native structure)
public Picture pictureFromBitmap(Bitmap src) {
Picture dst = Picture.create((int) src.getWidth(), (int) src.getHeight(), ColorSpace.RGB);
pictureFromBitmap(src, dst);
return dst;
}
public void pictureFromBitmap(Bitmap src, Picture dst) {
int[] dstData = dst.getPlaneData(0);
int[] packed = new int[src.getWidth() * src.getHeight()];
src.getPixels(packed, 0, src.getWidth(), 0, 0, src.getWidth(), src.getHeight());
for (int i = 0, srcOff = 0, dstOff = 0; i < src.getHeight(); i++) {
for (int j = 0; j < src.getWidth(); j++, srcOff++, dstOff += 3) {
int rgb = packed[srcOff];
dstData[dstOff] = (rgb >> 16) & 0xff;
dstData[dstOff + 1] = (rgb >> 8) & 0xff;
dstData[dstOff + 2] = rgb & 0xff;
}
}
}

Community
- 1
- 1

Gaurav Vachhani
- 349
- 2
- 8
-
Thank you for your reply, Can you tell me how to use this, I mean where to implement this code. – Harini Pasupathy Jul 07 '15 at 12:59
1
http://wptrafficanalyzer.in/blog/image-slideshow-using-viewflipper-in-android/
Hope this may help you,Or you can search for image slider in android to create image slide show

Vaisakh N
- 780
- 1
- 11
- 27
-
Thanks for your reply, but instead of using the slide show i can use the animation to view the images but the problem is, the taken animation will not be in the video form like mp4 format .For that what can i do. – Harini Pasupathy Jul 07 '15 at 12:39
-
http://stackoverflow.com/questions/3688993/encode-a-series-of-images-into-a-video – Vaisakh N Jul 07 '15 at 12:47