我正在开发一个应用程序,它从前置摄像头捕获实时视频流并将其发送到远程端(使用RTP)。 本质上,数据流是:AVCaptureSession - > AVCaptureVideoDataOutput - >回调 - > RTP - >在远程显示
当我使用横向模式时,远程端的图像是颠倒的。在纵向模式下,它向左旋转。
如何在以下回调中旋转像素缓冲区,以使远端的图像具有正确的方向?感谢任何指针。
void)captureOutput:(AVCaptureOutput *)captureOutput
didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
fromConnection:(AVCaptureConnection *)connection
答案 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)。