Video is low-quality with "skewed" output colors?
<p>i am developing a video recording application using android 2.1 and a sony ericcson xperia mini, it needs to take video and save it in to the sd card, but the problem is the quality of the output video file, it seems duplicated and just in green and purple colors, what is wrong?,here is the code:</p>

<pre><code>public class VideoAndroidActivity extends Activity implements SurfaceHolder.Callback{
private Button startIt;
private Button finishIt;
private SurfaceView surfaceView;
private SurfaceHolder surfaceHolder;
private Camera camera;
private boolean previewRunning;

private MediaRecorder mediaRecorder;
private final int maxDurationInMs = 20000;
private final long maxFileSizeInBytes = 500000;
private final int videoFramesPerSecond = 30;
private File tempFile;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    startIt = (Button) findViewById(R.id.button1);
    finishIt = (Button) findViewById(R.id.button2);

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

    startIt.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            startRecording();
        }
    });

    finishIt.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            stopRecording();
        }
    });
}

public void surfaceChanged(SurfaceHolder holder, int format, int width,int height) {
    if (previewRunning){
        camera.stopPreview();
    }

    Camera.Parameters parameters = camera.getParameters(); 
    List&lt;Camera.Size&gt; sizes = parameters.getSupportedPreviewSizes(); 
    Camera.Size cs = sizes.get(1); 
    parameters.setPreviewSize(cs.width, cs.height); 
    camera.setParameters(parameters);

    try {
        camera.setPreviewDisplay(holder);
        camera.startPreview();
        previewRunning = true;
    }
    catch (IOException e) {
    }
}

public void surfaceCreated(SurfaceHolder holder) {
    camera = Camera.open();
    if (camera != null){
        Camera.Parameters params = camera.getParameters();
        camera.setParameters(params);
    }
    else {
        Toast.makeText(getApplicationContext(), "Camera not available!", Toast.LENGTH_LONG).show();
        finish();
    }
}

public void surfaceDestroyed(SurfaceHolder holder) {
    camera.stopPreview();
    previewRunning = false;
    camera.release();
}

public boolean startRecording(){
    try {
        camera.unlock();
        mediaRecorder = new MediaRecorder();
        mediaRecorder.setCamera(camera);
        mediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);


        mediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
        mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);

        mediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
        mediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.MPEG_4_SP);

        mediaRecorder.setMaxDuration(maxDurationInMs);
        String extStorageDirectory = Environment.getExternalStorageDirectory().toString();
        tempFile = new File(extStorageDirectory, "/video1.mp4");
        mediaRecorder.setOutputFile(tempFile.getPath());

        mediaRecorder.setVideoFrameRate(videoFramesPerSecond);
        mediaRecorder.setVideoSize(surfaceView.getWidth(), surfaceView.getHeight());

        mediaRecorder.setPreviewDisplay(surfaceHolder.getSurface());
        mediaRecorder.setMaxFileSize(maxFileSizeInBytes);
        mediaRecorder.prepare();
        mediaRecorder.start();
        return true;
    } catch (IllegalStateException e) {
        e.printStackTrace();
        return false;
    } catch (IOException e) {
        e.printStackTrace();
        return false;
    }
}

public void stopRecording(){
    mediaRecorder.stop();
    camera.lock();
}
</code></pre>

<p>}</p>
