Grafika and OpenGL to record a video on android in square shape

I am currently trying to record a video in square shape and create a output as .mp4. It seems to be really challenging. I tried diffrent approches including: OnPreviewFrame and FFMpeg. But never got a satisfing result. Today i found Grafika. And it seems to be the right way. But because of the complextity of the Code i am stuck now. Using the Example: i managed to record a video. But its shape is rectangluar and not square. Furthermore the camera is rotated by 90 degrees. I was already trying to manipulate certain parameters but never got a good video. Some where squeezed and so on.

Does anybody know what parameters i need to change inside Grafikas example to get the right result? In the end the camera of my android phone should record Videos like Vine or Instagram.

Thanks for your help!


A few notes:

  1. CameraCaptureActivity is complicated because it's trying to use GLSurfaceView (originally to answer this question). ContinuousCaptureActivity is a better choice.

  2. You can't generally constrain the camera preview to an arbitrary shape by setting Camera parameters. You have to accept the image or video frames it gives you, then modify them to look the way you want. In your case, that means stripping off the top/bottom or left/right edges.

  3. I'm pretty sure Instagram is no longer strictly square. So you may be behind the times. :-)

The Grafika code works by feeding the Camera into a SurfaceTexture, which turns the camera frames into GLES textures. You can then render the texture however you like. By selecting a square shape, and modifying the texture coordinates, you can have square video.

The best place to start is with the "texture from camera" Activity. Note in particular the "zoom" feature, which adjusts the texture coordinates to select the inner part of the image. You can modify ScaledDrawable2d#getTexCoordArray() to map the inner portion of the frame, and modify the render code to use a square quad. Feed that into a video encoder.

Need Your Help

What is the maximum number of joins allowed in SQL Server 2008?

sql-server-2008 join

What is the maximum number of joins allowed in SQL Server 2008?