Author Topic: Video Capture  (Read 5838 times)

Offline sushobhit

  • long
  • ***
  • Posts: 109
  • future is now
    • View Profile
    • ANDROID APPS
Video Capture
« on: March 19, 2014, 10:38:37 am »
Ok now that the Game is developed it has to be posted to the market.
Great !!! Wait .. now wouldnt it be interseting if I could capture the Video of the game
during play.....it would be great for marketing right!!! but how...

Now I know it is quite possible as everytime a new Bitmap is created in onDrawFrame
or to be more specific frame...

So what I want is to somehow save each frame in image format
and then later on compile all these images into a single video file

Something like :
onDrawFrame(fb)
{
fb.clear(RGBCOLOR);
world.renderscene(fb);
world.draw(fb);
fb.display();
world.savecurrentframeimageBMP(OUTPUTSTREAM);
}

Can anybody tell how it can be made possible...
Something like taking ScreenShots....

Now that I think of it this technique can also be applied for making animated movies.

Eg : In the game music ride 2 posted in Projects (JPCT) there is video of game being played in realtime . 8)

Offline sushobhit

  • long
  • ***
  • Posts: 109
  • future is now
    • View Profile
    • ANDROID APPS
Re: Video Capture
« Reply #1 on: March 19, 2014, 10:44:05 am »
View content = findViewById(R.id.layoutroot);
    Bitmap bitmap = content.getDrawingCache();
    File file = new File( Environment.getExternalStorageDirectory() + "/test.png");
    try
    {
        file.createNewFile();
        FileOutputStream ostream = new FileOutputStream(file);
        bitmap.compress(CompressFormat.PNG, 100, ostream);
        ostream.close();
    }
    catch (Exception e)
    {
        e.printStackTrace();
    }

Can this be used with GLViews

Offline sushobhit

  • long
  • ***
  • Posts: 109
  • future is now
    • View Profile
    • ANDROID APPS
Re: Video Capture
« Reply #2 on: March 19, 2014, 01:19:16 pm »
I tried GLView.getDrawingCache();

Returns empty bitmap... ???

Can I get bitmap from the world.getCamera();

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Video Capture
« Reply #3 on: March 19, 2014, 03:26:55 pm »
You can obtain the current image from the FrameBuffer by using the getPixels()-methods. They return an int[]-array that you can convert into a Bitmap and save it as an image. This will be very slow and not even close to real time though.

Offline sushobhit

  • long
  • ***
  • Posts: 109
  • future is now
    • View Profile
    • ANDROID APPS
Re: Video Capture
« Reply #4 on: March 20, 2014, 05:53:48 am »
but why is mGLView.getDrawingCache() // Returns Bitmap
not working

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Video Capture
« Reply #5 on: March 20, 2014, 09:34:29 am »
I think that this is something different. It's for rendering a view into a cache. I don't think that it applies to native gl output.

Offline sushobhit

  • long
  • ***
  • Posts: 109
  • future is now
    • View Profile
    • ANDROID APPS
Re: Video Capture
« Reply #6 on: March 20, 2014, 02:02:29 pm »
Yes but why cant we get the getDrawingCache()

Is there someway to achieve the aforesaid with this method

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Video Capture
« Reply #7 on: March 20, 2014, 03:08:52 pm »
Because...there is none? Why do you insist on using this cache? After all, there is nothing to cache because the image updates every frame anyway. Just grab the pixels and you should be fine.

Offline sushobhit

  • long
  • ***
  • Posts: 109
  • future is now
    • View Profile
    • ANDROID APPS
Re: Video Capture
« Reply #8 on: March 22, 2014, 07:47:09 am »
Ok getPixels is good but it's really a very slow process
I want to make a video


Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Video Capture
« Reply #9 on: March 22, 2014, 09:19:20 am »
Then either grab the images via HDMI connection with some capture device (i never tried this, but people are doing so it has to work) or grab the video directly on the device, if it's rooted and fast enough...my old Galaxy Note (the only rooted device that i own) can't really handle this.

Offline sushobhit

  • long
  • ***
  • Posts: 109
  • future is now
    • View Profile
    • ANDROID APPS
Re: Video Capture
« Reply #10 on: March 27, 2014, 08:16:33 am »
I think i will borrow a handycam and shoot in dark !!!!!! :-[

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Video Capture
« Reply #11 on: March 27, 2014, 08:22:16 am »
I think i will borrow a handycam and shoot in dark !!!!!! :-[
That's what i do too. If you have a second device, you can use that as well to capture the first one.

Offline sushobhit

  • long
  • ***
  • Posts: 109
  • future is now
    • View Profile
    • ANDROID APPS
Re: Video Capture
« Reply #12 on: March 27, 2014, 02:57:11 pm »
By the way I am facing a very peculiar problem

I have made a truck model and the truck has four cylinders as tyres.
Now i have used joint rotation to animate the tyres ..
When I export the MD2(mikshaper3d) and load the animation (ie object.animate(ind,frame);)
The animation is very very creepy the tyres rotate as specified but after some time during the anim they shrink and then again expand .
So I loaded the anim in milkshape MD2 viewer , there was a same problem there too
But when I disable interpolation the anim runs fine (what is happening what's the problem)
So how do i disable interpolation in JPCT (of the object)

Offline rainfalls

  • byte
  • *
  • Posts: 27
    • View Profile
Re: Video Capture
« Reply #13 on: April 02, 2014, 10:32:11 pm »
I don't fully understand the underlying mechanism of Object.animate() method and how you were using it, but I doubt you were using Matrix.interpolate(...)  to interpolate your translation matrix.

Actually translation matrices can't be simply interpolated through linear interpolation of their elements, as what Matrix.interpolate() method does.

Generally you have to:

1) decompose matrices into simpler transformations: translation, rotation, scale;

or

2) convert matrices to quaternions instead,

then do the linear interpolations and finally convert back to get the new translation matrix.



By the way I am facing a very peculiar problem

I have made a truck model and the truck has four cylinders as tyres.
Now i have used joint rotation to animate the tyres ..
When I export the MD2(mikshaper3d) and load the animation (ie object.animate(ind,frame);)
The animation is very very creepy the tyres rotate as specified but after some time during the anim they shrink and then again expand .
So I loaded the anim in milkshape MD2 viewer , there was a same problem there too
But when I disable interpolation the anim runs fine (what is happening what's the problem)
So how do i disable interpolation in JPCT (of the object)

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Video Capture
« Reply #14 on: April 03, 2014, 10:19:38 am »
I think that this question is more related to the interlation of keyframes. A linear interpolation on them can look strange if there aren't enough in between keyframes defined. So either add more keyframes to the animation or disable linear interpolation by using Object3D.getAnimationSequence().setInterpolationMethod(....);