android camera x旋转,Android CameraX how to rotate output video

在使用Android CameraX捕获并编码为H264的视频时,发现SurfaceView上显示的视频在竖屏模式下逆时针旋转了90度,而横屏模式下没有旋转。尝试通过设置imageAnalysis.targetRotation未解决问题,同时对YUV数据进行旋转导致颜色变暗。寻求正确旋转视频的方法,避免颜色失真,不改变预览效果。
摘要由CSDN通过智能技术生成

I use the following versions of CameraX dependencies:

implementation "androidx.camera:camera-camera2:1.0.0-beta04"

implementation "androidx.camera:camera-view:1.0.0-alpha11"

implementation "androidx.camera:camera-extensions:1.0.0-alpha11"

implementation "androidx.camera:camera-lifecycle:1.0.0-beta04"

And try to encode output video from the camera into H264 using android MediaCodec and decode it back and show the result video on a SurfaceView, everything works fine except that the video on a SurfaceView is conterclockwise rotated by 90 degrees in portrait mode and has no rotation in landscape mode.

My code of capturing video from the camera looks like this:

private lateinit var yData: ByteArray //

private lateinit var uData: ByteArray // store YUV data from camera

private lateinit var vData: ByteArray //

imageAnalysis = ImageAna

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值