Android camera capture produces green and blocky v

2019-04-11 06:14发布

问题:

I'm trying to record video with camera in android, but any output format i put produces a green and blocky video (though with normal sound)..

So here are the parameters i set (i tried h264 and mpeg_4_sp too)

mediaRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
mediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
mediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
mediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H263);

The native camera capture app does save the video ok (and it has h263 in configurations set)

Any ideas why it may occur in my app? Is there any other special settings to put here?

ps: my android version i use for test is 2.2.1 with BiffMod v2.1

EDIT

this is how it looks on both Android and PC media players: http://i52.tinypic.com/2rcbwau.jpg

回答1:

Ok, i solved the issue myself..

The problem was in the video resolution, it should be explicitly set to 320x240 (perhaps other standard sizes like 640x480 are ok too, but only this one worked fine for me) so recorder.setVideoSize(320,240); solved the whole green blocky video bug