【问题标题】:AVCaptureSession rotate | orientation while video transmittingAVCaptureSession 旋转 |视频传输时的方向
【发布时间】:2014-12-01 21:14:42
【问题描述】:

我正在开发视频流应用程序,其中我需要捕获前置摄像头视频帧并编码然后传输到另一端,典型流程是这样的

AVCaptureSession -> AVCaptureDeviceInput -> AVCaptureVideoDataOutput -> 捕获帧--> 编码帧--> 发送帧到另一端,

它工作正常,我已将 kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange 设置为帧格式。

也用于显示预览的预览层,

当设备方向发生变化时,问题就来了Capture 回调,但看起来,预览层只是向我显示捕获的缓冲区的预览,并且 UI 对缓冲区进行了调整,而在另一端我会得到咆哮的缓冲区,

所以我想知道,是否有任何配置可以使其更改,或者我是否需要在捕获缓冲区回调中旋转/转换缓冲区。

【问题讨论】:

  • 你是怎么抓帧的?
  • 我的意思是在回调函数中 - (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection

标签: ios video objective-c++ avcapturesession avcapturedevice


【解决方案1】:

感谢您的研究,基本上解决方案是,应该设置连接方向,我正在玩预览层,所以它影响预览层但不影响方向。

这里是代码 sn-p

-(void) orientationChanged
{
    // get the new orientation from device 
    AVCaptureVideoOrientation newOrientation = [self videoOrientationFromDeviceOrientation];

    // set the orientation of preview layer :( which will be displayed in the device )
    [previewLayer.connection setVideoOrientation:newOrientation];

    // set the orientation of the connection: which will take care of capture
    [pCaptureConnection setVideoOrientation:newOrientation];

}

【讨论】:

  • 什么是 pCaptureConnection??
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-09-22
  • 2012-06-15
  • 2014-11-19
相关资源
最近更新 更多