Hi, I have tried several different types of code to record video and audio on android. I am using the UDOO dual with android 4.4 kitkat. I try to use the MediaRecorder. But is does not seems to find a correct videoSource. When i try to set the videoSize or VideoEncoder or VideoFramerate the software crashes without usefull debug info. Even the try/catch block gives an empty exception. I hope someone can help me Thanks in advance, Tom
A few questions then: Do you have granted permission in you android manifest? Code: <uses-permission android:name="android.permission.CAMERA" /> <uses-feature android:name="android.hardware.camera" /> try to use something like this to get the camera preview, to check if it work Code: public class MainActivity extends Activity implements TextureView.SurfaceTextureListener { private Camera mCamera; private Camera.CameraInfo info; private TextureView mTextureView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mTextureView = (TextureView) findViewById(R.id.camera_texture); mTextureView.setSurfaceTextureListener(this); } @Override public void onSurfaceTextureAvailable(SurfaceTexture surfaceTexture, int width, int height) { Log.i(DEBUG, "onSurfaceTextureAvailable"); info = new Camera.CameraInfo(); for (int i = 0; i < Camera.getNumberOfCameras(); i++) { Camera.getCameraInfo(i, info); Log.i(DEBUG, "info: "+ info.facing); //mCamera = Camera.open(i); } //make portrait //mCamera.setDisplayOrientation(90); try { /* Tell the camera to write onto our textureView mTextureView */ mCamera.setPreviewTexture(surfaceTexture); mCamera.startPreview(); } catch (IOException ioe) { Log.e("camera-reverse", ioe.getMessage()); } } @Override public boolean onSurfaceTextureDestroyed(SurfaceTexture surfaceTexture) { Log.i(DEBUG, "onSurfaceTextureDestroyed"); if (null != mCamera) { mCamera.stopPreview(); mCamera.release(); } return true; } @Override public void onSurfaceTextureUpdated(SurfaceTexture surfaceTexture) { //Log.i(DEBUG, "onSurfaceTextureUpdated"); } @Override public void onSurfaceTextureSizeChanged(SurfaceTexture arg0, int arg1, int arg2) { // TODO Auto-generated method stub }
That is no problem. i had the permissions in my app so that was not the issue I do get the preview now! Thank you How do i record the video now preferrably with the audio stream from the mic input