【问题标题】:rotate iphone video data旋转iphone视频数据
【发布时间】:2013-02-27 19:53:18
【问题描述】:

我正在开发一个应用程序,该应用程序从前置摄像头捕获实时视频流并将其发送到远程端(使用 RTP)。 本质上数据流是: AVCaptureSession -> AVCaptureVideoDataOutput -> 回调 -> RTP -> 在远程端显示

当我使用横向模式时,远程端的图像是颠倒的。在纵向模式下,它会向左旋转。

如何在以下回调中旋转像素缓冲区,以使远端的图像具有正确的方向?感谢任何指针。

void)captureOutput:(AVCaptureOutput *)captureOutput
didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
       fromConnection:(AVCaptureConnection *)connection

【问题讨论】:

  • 我也遇到了同样的问题,你还没有找到解决办法吗?

标签: iphone ios ios5 ios6 avfoundation


【解决方案1】:

到目前为止,我能够得到一半的解决方案:

- (void) willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation) toInterfaceOrientation duration:(NSTimeInterval)duration
{

    switch (toInterfaceOrientation)
    {
        case UIInterfaceOrientationLandscapeRight:
            [[[self imageView] layer] setAffineTransform:CGAffineTransformMakeRotation(0)];
            break;
        case UIInterfaceOrientationLandscapeLeft:
            [[[self imageView] layer] setAffineTransform:CGAffineTransformMakeRotation(M_PI)];
            break;
//        case UIInterfaceOrientationPortrait:
//            [[[self imageView] layer] setAffineTransform:CGAffineTransformMakeRotation(M_PI / 2)];
//            break;
//        case UIInterfaceOrientationPortraitUpsideDown:
//            [[[self imageView] layer] setAffineTransform:CGAffineTransformMakeRotation(-M_PI / 2)];
//            break;
    }
}

我重写了 willAnimitateRotation 函数,但这仅适用于 Landscape-Orientations(我在 Landscape-Mode 中设计了 ViewController)。

【讨论】:

    猜你喜欢
    • 2012-04-26
    • 1970-01-01
    • 2014-03-17
    • 2014-05-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-06
    • 1970-01-01
    相关资源
    最近更新 更多