Video Capture

Started by sushobhit, March 19, 2014, 10:38:37 AM

Previous topic - Next topic

sushobhit

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)

sushobhit

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

sushobhit

I tried GLView.getDrawingCache();

Returns empty bitmap... ???

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

EgonOlsen

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.

sushobhit

but why is mGLView.getDrawingCache() // Returns Bitmap
not working

EgonOlsen

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.

sushobhit

Yes but why cant we get the getDrawingCache()

Is there someway to achieve the aforesaid with this method

EgonOlsen

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.

sushobhit

Ok getPixels is good but it's really a very slow process
I want to make a video


EgonOlsen

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.

sushobhit

I think i will borrow a handycam and shoot in dark !!!!!! :-[

EgonOlsen

Quote from: sushobhit on March 27, 2014, 08:16:33 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.

sushobhit

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)

rainfalls

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.



Quote from: sushobhit 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)

EgonOlsen

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(....);