According to this answer in the update #2 section is there any way to provide the Surface from glSurfaceview to the MediaRecorder?
Or it has to implement from the SurfaceView like in the RecordableSurfaceView which use MediaRecorder and in the grafika which use MediaCodec?
Update:
After do some more searching I found this which may be the answer. By the way as I have said in the title, I only need to record the rendered glSurfaceView so I'm still open to any suggestion that helps me achieve it.
Another good reference
Related
I have to create a circular video player using textureview in android. I don't have idea how to achieve this. Kindly help.
It's possible to modify the Camera output as you record it, but this has nothing to do with TextureView. You can use a GLES fragment shader or apply a mask bitmap with GLES. Grafika ( github.com/google/grafika ) has some relevant code, but doesn't do what you're specifically asking for
You can achieve by providing overlay of TextureView
here is sample how you can achieve!
I need to record a video that just contains one single frame: an image specified by the user (it can be of any length, but it will only have the same static image). So, I figured I could use the new MediaRecorder.VideoSource.SURFACE and just draw to the Surface being used by the recorder. I initialize the recorder properly, and I can even call MediaRecorder.getSurface() without an exception (something that is apparently tricky).
My problem is somewhat embarrassing: I don't know what to do with the surface returned. I need to draw to it somehow, but all examples I can find involve drawing to a SurfaceView. Is this surface the same surface used by MediaRecorder.setPreviewDisplay()? How do I draw something to it?
In theory you can use Surface#lockCanvas() to get a Canvas to draw on if you want to render in software. There used to be problems with this on some platforms; not sure if that has been fixed.
The other option is to create an EGLSurface from the Surface and render onto it with OpenGL ES. You can find examples of this, with some code to manage all of the EGL setup, in Grafika.
The GLES recording examples uses MediaCodec rather than MediaRecorder, but the idea is the same, and it should be much simpler with MediaRecorder.
I've seen many threads on this but cannot figure out what is the best possible way of doing camera capture without having a preview.
The way that I am doing it now is that I create a SurfaceTexture like this:
SurfaceTexture fakePreview = new SurfaceTexture(10);
The fakePreview object is not used for any other purpose and is just set as the preview texture, and disposed of when finished with the Activity.
The fakePreview SurfaceTexture is set and the preview then started like this:
mCamera.setPreviewTexture(fakePreview);
mCamera.startPreview();
This seems to work fine, but I'm using a rather low-quality sensor and would like to get the highest possible capture quality out of it. So I'm always looking for ways to improve upon this.
I've seen a few methods other than this for starting the camera without showing preview such as setting up a preview normally but setting it's size to 0x0dp: https://stackoverflow.com/a/9745780/593340
As well as using a dummy surfaceholder.callback: https://stackoverflow.com/a/23621826/593340
My question is is there any advantages or disadvantages by using the method I described above?
If my method has issues, do the two other examples posted represent a better answer or are they just as bad?
Thirdly, am I gaining any performance by neglecting to show preview or am I just causing potential bugs by doing this?
Thanks for looking!
-Rob
The accepted answer for avoiding the black flicker on VideoView is to do something like the following. This works great, in fact it's smooth and I can reset the video, change the file and everything without a flicker.
Now...How can I draw a View on top of the VideoView?
mVideoView.setZOrderMediaOverlay(true);
mVideoView.setZOrderOnTop(true);
The order of the view on the layout makes no difference at all, since we are calling those methods. I would love to show you guys a screenshot of what's going on but it's simply drawing the video over the other views.
Hate answering my own questions but here it goes:
The least painful way of doing this is actually to avoid using a VideoView and resulting to the use of a TextureView and playing the video in its surface. That way it doesn't necessarily try to be on top of everything but still allows us to draw things over it.
I've been using SurfaceView and Canvas to draw Bitmaps to the screen. I've been looking into using videos to speed up some animation, but drawing Bitmaps and playing videos are two different things. Is it possible to draw both Bitmaps and videos to the screen? According to this post it doesn't sound possible, but maybe there's another way?
The last comment in there seems to indicate that he got it working. Instead of trying to layer a VideoView and your SurfaceView you are going to have to make yourself a MediaPlayer and set it up to play on a designated portion of the SurfaceView that you already have. VideoView is made up of a MediaPlayer and a SurfaceView, and you are disallowed from stacking two SurfaceViews.
That link to the api demos in the last comment from your question shows you how you "tie together" a SurfaceView and a MediaPlayer to make it show a video file.