7

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.

Hemantvc
  • 2,111
  • 3
  • 30
  • 42

2 Answers2

0

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);
Codemaker2015
  • 12,190
  • 6
  • 97
  • 81
-4

Nothing you just set the rotation for the videoview that's all

          videoView.setRotation(90f);

          (or)


<VideoView
    android:id="@+id/videoView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true"
    android:rotation="90" />
Naveen Kumar Kuppan
  • 1,424
  • 1
  • 10
  • 12
  • 2
    It would display black screen as videoView inherently uses surface view. Because a SurfaceView’s content does not live in the application’s window, it cannot be transformed (moved, scaled, rotated) efficiently. – Jaydev Aug 06 '16 at 11:40