This is the code that I used to record video from an Android device in MP4 format. The file is created, but has a size of 0 bytes. I donβt seem to understand what went wrong. Any help would be appreciated.
if(mCamera == null) { mCamera = Camera.open(); mCamera.unlock(); } if(mediaRecorder == null) mediaRecorder = new MediaRecorder(); mediaRecorder.setCamera(mCamera); mediaRecorder.setCamera(mCamera); mediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC); mediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA); mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4); mediaRecorder.setMaxDuration(maxDurationInMs); mediaRecorder.setOutputFile("/sdcard/1.mp4"); mediaRecorder.setVideoFrameRate(videoFramesPerSecond); mediaRecorder.setVideoSize(176,144); mediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.DEFAULT); mediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.MPEG_4_SP); mediaRecorder.setPreviewDisplay(surface); mediaRecorder.setMaxFileSize(maxFileSizeInBytes); mediaRecorder.prepare(); try { mediaRecorder.prepare(); } catch (IllegalStateException e) {
source share