Android中的视频视图旋转90度

7

我希望将视频旋转90度。

目前我已经旋转了布局,但是视频无法播放。 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 请帮帮我。

请看这个链接:https://dev59.com/R2oy5IYBdhLWcg3wZdGr - Dunken
2个回答

0
使用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);

-4

没有什么,你只是为videoview设置了旋转而已。

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

2
由于videoView本身使用surface view,因此它会显示黑屏。因为SurfaceView的内容不存储在应用程序的窗口中,所以无法高效地进行转换(移动、缩放、旋转)。 - Jaydev

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接