I am using textureView for getting the video input from android camera. The problem is that if I give a 720p 60fps input, there is very significant frame drop in the output shown by camera preview. I tried both surfaceView and GLSurfaceView, they also show similar behavior. Is there any better way to acheive 60fps using camera preview or rather can we achieve 60fps using android camera?
Related
We are using camera2 API to get preview and encode video simultaneously, using mediacodec.
We know when we should rotate the camera by querying 'CameraCharacteristics.SENSOR_ORIENTATION' but there is only preview rotation option.
What we need is to rotate the surface which goes to the encoder so we will not get video upside down. (Or rotate the camera itself like the old camera API.)
Thanks
I have tried by setting the videosize(width,height) for mediarecorder, but this has device compatibility issue, on few devices its crashing at mediarecorder.start();
If the device happens to support a square video size, you are welcome to use it. Most will not.
Vine, based on the last reports that I heard, does not use MediaRecorder. Instead, they use preview frames from the camera, which they crop to be square and assemble into a video. I do not know what Instagram does.
You are also welcome to record a non-square video, then post-process the video yourself to crop it to be square.
I'm building my own camera application and I'm looking for a way to take a picture while recording a video. (android 15+)
Is this possible in CWAC-camera or should I cut a frame out of the video.
Thanks
Is this possible in CWAC-camera
Not that I am aware of.
should I cut a frame out of the video
It is possible that a PreviewCallback is invoked while MediaRecorder is recording. I have not experimented with that. If it is, my guess is that will give you better results than will grabbing a frame.
I'm using Google Glass to stream video, and need to grab the camera frames. I'm using the OnPreviewFrame() callback to get it, and everything is fine with resolution up to 800x480. When trying to do the same with 720p resolution I get a corrupted frame. If I save the data to file and try to show it as 720p NV21 frame, it is completely corrupted. I played around a bit, and discovered that if I show it with 1288 width, I can recognize what of the image, but it still has some issues with it. I'm using SurfaceTexture for the preview.
The same code works fine on Nexus7.
So it turns out Glass has an issue with 720p60 preview. When I changed the frame rate to 30fps, I got perfect 720p frames
In your init preview method, did you set parameters like this?
parameters.setPreviewFpsRange(30000, 30000);
parameters.setPreviewSize(640, 360);
mCamera.setParameters(parameters);
I found with these settings, my Glass preview would look distorted.
I am working on application that does some real time image processing on camera frames. For that, I use preview callback's method onPreviewFrame. This works fine for cameras that support preview frames that have resolution at least 640x480 or larger. But when camera does not support such large camera preview resolution, application is programmed to refuse processing such frames. Now, the problem I have is with phones like Sony Xperia Go. It is a very nice device that can record video up to resolution 1280x720, but unfortunately maximum camera preview size is 480x320, which is too small for my needs.
What I would like to know is how to obtain these larger camera frames (up to 1280x720 or more)? Obviously it has to be possible because camera application has the ability to record videos in that resolution - therefore this application somehow must be able to access those larger frames. How to do the same from my application?
Application has to support Android 2.1 and later, but I would be very happy even if I find the solution for my problem only for Android 4.0 or newer.
This question is similar to http://stackoverflow.com/questions/8839109/processing-android-video-frame-by-frame-while-recording, but I don't need to save the video - I only need those high resolution video frames...
It seems the only thing you can do is decoding frames from MediaRecoder data.
You may use ffmpeg to decode recoreder data from LocalSocket.
Hope the following open source projects may help:
ipcamera-for-android: https://code.google.com/p/ipcamera-for-android/
spydroid-ipcamera: https://code.google.com/p/spydroid-ipcamera/
You should probably take a look at the OpenCV library.
It has methods that allow you to receive full frames.
I have an impression: video preview size is small, and is slow, slower than the set video recording frame rate.
I was once trying to look for solutions on this. It seems a better way is to get the video stream from the video recorder, then directly process the data from the video stream.
You could find some examples on Android ip-camera.
You can use this library:
https://github.com/natario1/CameraView
This library has addFrameProcessor listener that in process function has Frame parameter.
If you need to record video while frame processing, you need to use from takeVideoSnapshot function of CameraView. takeVideo stop frame processing until complete video recording in latest version I tested 2.6.4.