旋转iphone视频数据

时间:2013-03-12 10:37:26

标签: iphone ios ios5 ios6 avfoundation

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

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

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

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

1 个答案:

答案 0 :(得分:0)

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

- (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)。