Question

Has anyone had success with recording 480x360 h264 video from a Samsung Galaxy Nexus (running 4.3 - initially tried with 4.2) via the MediaRecorder API? I am able to record at 640x480 but as soon as I change it to 480x360 the MediaRecorder API crashes when start() is called - with an error of -19.

These are my settings:

mCamera.unlock();

mMediaRecorder = new MediaRecorder();

mMediaRecorder.setCamera(mCamera);
mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);

mMediaRecorder.setMaxDuration(300000); //5min

mTempFile = new File(getFilesDir(), AppManager.tempFileName);
mMediaRecorder.setOutputFile(mTempFile.getPath());

mMediaRecorder.setVideoEncodingBitRate(1048576); //1mb/s
mMediaRecorder.setVideoSize(480, 360);
mMediaRecorder.setVideoFrameRate(30);

mMediaRecorder.setAudioEncodingBitRate(131072); //128kb/s
mMediaRecorder.setAudioSamplingRate(44100); //Hz/s

mMediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
mMediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);

mMediaRecorder.setPreviewDisplay(mSurfaceHolder.getSurface());

mMediaRecorder.setMaxFileSize(104857600); //100mb

mMediaRecorder.prepare();
mMediaRecorder.start(); //<<<crashes here

Any ideas on why this would crash, when for example it works on a cheap tablet running 4.1?

Any help would be much appreciated, thank you!

Was it helpful?

Solution

Thanks for the comments. It's just not possible, as to why I have no idea but this is also true of the Galaxy S3 and another small cheap tablet I've now tested on. It's a shame because 480x320 seems to be the baseline profile to play on all Android devices.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top