4

I want to make video of my android screen(what i am doing on the android screen) programatically.

Is there any best tutorial or help regarding this. I have searched a lot but i found that thing...(Capture the android screen picture programtically). Ok fine if i capture a lot of images after each milliseconds than how i make video with a lot of captured images in android programmatic.

Lucifer
  • 29,392
  • 25
  • 90
  • 143
Jaffar Raza
  • 311
  • 1
  • 6
  • 19

3 Answers3

6

you can use following code for screen capturing in Android.

Please view this url..... http://android-coding.blogspot.in/2011/05/create-custom-dialog-with-dynamic.html

Akhil
  • 76
  • 2
  • 6
    Welcome to Stack Overflow! While this may theoretically answer the question, [it would be preferable](http://meta.stackexchange.com/q/8259) to include the essential parts of the answer here, and provide the link for reference. – Bill the Lizard Mar 20 '12 at 12:50
2

As long as you have bitmaps you can flip it into video using JCodec ( http://jcodec.org ).

Here's a sample image sequence encoder: https://github.com/jcodec/jcodec/blob/master/src/main/java/org/jcodec/api/SequenceEncoder.java . You can modify it for your purposes by replacing BufferedImage with Bitmap.

Use these helper methods:

public static Picture fromBitmap(Bitmap src) {
  Picture dst = Picture.create((int)src.getWidth(), (int)src.getHeight(), RGB);
  fromBitmap(src, dst);
  return dst;
}

public static void fromBitmap(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;
    }
  }
}

public static Bitmap toBitmap(Picture src) {
  Bitmap dst = Bitmap.create(pic.getWidth(), pic.getHeight(), ARGB_8888);
  toBitmap(src, dst);
  return dst;
}

public static void toBitmap(Picture src, Bitmap dst) {
  int[] srcData = src.getPlaneData(0);
  int[] packed = new int[src.getWidth() * src.getHeight()];

  for (int i = 0, dstOff = 0, srcOff = 0; i < src.getHeight(); i++) {
    for (int j = 0; j < src.getWidth(); j++, dstOff++, srcOff += 3) {
      packed[dstOff] = (srcData[srcOff] << 16) | (srcData[srcOff + 1] << 8) | srcData[srcOff + 2];
    }
  }
  dst.setPixels(packed, 0, src.getWidth(), 0, 0, src.getWidth(), src.getHeight());
}

You can as well wait for JCodec team to implement full Android support, they are working on it according to this: http://jcodec.org/news/no_deps.html

Stanislav Vitvitskyy
  • 2,297
  • 20
  • 17
  • 2
    Is this code supposed to run extremely slow? fromBitmap() took about 30-40 seconds to execute for a 480x800 image. JCodec's encodeNativeFrame() is taking even longer. Is there any way to rewire JCodec's internals to use Bitmaps instead of Pictures? – BVB Jun 13 '13 at 22:18
1

you can use following code for screen capturing in Android.

ImageView v1 = (ImageView)findViewById(R.id.mImage);
v1.setDrawingCacheEnabled(true);
Bitmap bm = v1.getDrawingCache();

For Creating Video from Images visit this link.

Lucifer
  • 29,392
  • 25
  • 90
  • 143