【问题标题】:Video view rotate 90 degree in android视频视图在android中旋转90度
【发布时间】:2014-03-31 10:41:11
【问题描述】:

我想将视频旋转 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

请帮帮我。

【问题讨论】:

标签: android


【解决方案1】:

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

【讨论】:

    【解决方案2】:

    你只是为视频视图设置旋转而已

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

    【讨论】:

    • 它将显示黑屏,因为 videoView 固有地使用表面视图。由于 SurfaceView 的内容不在应用程序的窗口中,因此无法有效地转换(移动、缩放、旋转)。
    猜你喜欢
    • 2012-04-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-21
    • 1970-01-01
    • 1970-01-01
    • 2016-09-23
    • 1970-01-01
    相关资源
    最近更新 更多