I am able to record a video on Android, but can I do so without previewing the video on my screen?

Here is the working code for the surfaceView:

surfaceView = (SurfaceView) findViewById(R.id.surface_camera);
surfaceHolder = surfaceView.getHolder();
surfaceHolder.addCallback(this);
surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);

Can I manually input the size of surfaceHolder instead of doing

surfaceHolder = surfaceView.getHolder();

Thank you

有帮助吗?

解决方案

Camera on android platform can't stream video without valid preview surface. You can resize the size of preview surface to 1x1 pixels.

其他提示

If the query getSupportedVideoSizes() returns null for camera parameters, then it means the camera has only preview stream and no separate recording stream. If thats not the case then recording can happen without the preview being started.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top