'Video view rotate 90 degree in android

I want to rotate video in 90 degree.

Current i rotate layout but video can't play. xml

<LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="horizontal"
        android:rotation="90" >

        <VideoView
            android:id="@+id/videoView"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent" />
    </LinearLayout>

java

videoView = (VideoView) findViewById(R.id.videoView);

          final Uri videoUri = Uri.parse(
               Environment.getExternalStorageDirectory().getAbsolutePath()+"/UnoPlayList/restaurant_menu_pro_mkv.mkv");

       videoView.setVideoPath(Environment.getExternalStorageDirectory().getAbsolutePath()+"/UnoPlayList/restaurant_menu_pro_mkv.mkv");
       //videoView.setRotation(180);
    //  videoView.setVideoURI(videoUri);
      videoView.start();

Is there any way to rotate video.

example: https://play.google.com/store/apps/details?id=com.mycall.videorotate&hl=en

Please help me.



Solution 1:[1]

Use camera.setDisplayOrientation() and recorder.setOrientationHint() methdos to rotate a video while capturing itself.

    camera = Camera.open();
    //Set preview with a 90° ortientation
    camera.setDisplayOrientation(90);
    camera.unlock();

    recorder = new recorder();
    recorder.setCamera(camera);
    recorder.setAudioSource(recorder.AudioSource.MIC);
    recorder.setVideoSource(recorder.VideoSource.CAMERA);
    recorder.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_720P));
    recorder.setPreviewDisplay(mPreview.getHolder().getSurface());
    recorder.setOutputFile(getOutputMediaFile(MEDIA_TYPE_VIDEO).toString());
    
    //Rotate video by 90 degree
    recorder.setOrientationHint(90);

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Codemaker