【问题标题】:How to fix mirror effect of captured video in Exoplayer如何修复 Exoplayer 中捕获的视频的镜像效果
【发布时间】:2020-01-23 12:16:16
【问题描述】:

我正在使用 ExoPlayer 显示捕获的视频,但是当 front_camera 捕获视频时,显示为翻转。

我试过翻转 exoplayerView exoPlayerView.scaleX= -1f

private fun videoPlayingMode() {

    capturedImageView.visibility = View.GONE
    exoPlayerView.visibility = View.VISIBLE
    //exoPlayerView.scaleX= -1f
}

我还实现了翻转功能以将捕获的图像转换为翻转,但我无法为捕获的视频实现此功能。

private fun flip(src: Bitmap): Bitmap {
    // create new matrix for transformation
    val matrix = Matrix()
    matrix.preScale(-1.0f, 1.0f)
    // return transformed image
    return Bitmap.createBitmap(src, 0, 0, src.width, src.height, matrix, true)
} 

我希望在使用前置摄像头拍摄视频时,不应翻转视频。 注意:我也使用了 CameraKit 库,但我没有使用 TextureView

【问题讨论】:

    标签: android kotlin camera exoplayer


    【解决方案1】:

    您可以旋转视图:

    VideoView.setRotation(180);
    

    【讨论】:

    【解决方案2】:

    我找到了解决方案并实施了它。问题已解决。

    fun loadVideo(videoUri: Uri) {
        if (camera?.facing == CameraKit.Constants.FACING_FRONT) {
            exoPlayerView.scaleY = -1f
        } 
    

    【讨论】:

      【解决方案3】:

      正如我尝试以下方式一样,前置摄像头录制的视频可以在 exoplayer 中镜像(翻转)显示:

      首先:将 app:surface_type="texture_view" 添加到您的 exo 播放器视图中,如下所示:

                  <com.google.android.exoplayer2.ui.PlayerView
                  android:id="@+id/exoPlayerView"
                  android:layout_width="match_parent"
                  android:layout_height="match_parent"
                  ...
                  **app:surface_type="texture_view"**
                  ... />
      

      第二个:从 exoPlayerView 获取 videoSurfaceView 并将比例设置为 -1,如下所示:

              binding.exoPlayerView.apply {
                  **videoSurfaceView?.scaleX = -1f**
              }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-05-31
        • 1970-01-01
        • 2017-12-26
        • 2018-04-17
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多