视频视图旋转90度在android

piok6c0g  于 2023-02-17  发布在  Android
关注(0)|答案(2)|浏览(156)

我想把视频旋转90度。
当前i旋转布局,但视频无法播放. 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();

有没有办法旋转视频。
示例:https://play.google.com/store/apps/details?id=com.mycall.videorotate&hl=en
请帮帮我。

7lrncoxx

7lrncoxx1#

使用camera.setDisplayOrientation()recorder.setOrientationHint()方法可在捕获视频时旋转视频。

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);
x8diyxa7

x8diyxa72#

没什么,你只是设置视频的旋转,就这样

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" />

相关问题