1

これは私のアプリをフリーズさせる私のコードです

 AVCaptureConnection *videoConnection = [videoOutput connectionWithMediaType:AVMediaTypeVideo];


if ([videoConnection isVideoOrientationSupported] )
{
    [videoConnection setVideoOrientation:AVCaptureVideoOrientationPortrait];

}

これは私のvideoOutput初期化です

// Setup video capture
videoInput = [[AVCaptureDeviceInput deviceInputWithDevice: front? frontVideoDevice: rearVideoDevice error: &error] retain];
videoOutput = [[AVCaptureVideoDataOutput alloc] init];
[videoOutput setAlwaysDiscardsLateVideoFrames: YES];
// Set the video output to store frame in BGRA (It is supposed to be faster)
NSString* key = (NSString*)kCVPixelBufferPixelFormatTypeKey; 
NSNumber* value = [NSNumber numberWithUnsignedInt:kCVPixelFormatType_32BGRA]; 
NSDictionary* videoSettings = [NSDictionary dictionaryWithObject:value forKey:key]; 
[videoOutput setVideoSettings:videoSettings]; 

2 回目にセッションを初期化するとアプリが応答しなくなりますが、avcaptureconnection のコードを削除すればすべて問題ありません

?

4

1 に答える 1

0

…!

[session startRunning] その前に電話 した

AVCaptureConnection *videoConnection = [videoOutput connectionWithMediaType:AVMediaTypeVideo];


if ([videoConnection isVideoOrientationSupported] )
{
    [videoConnection setVideoOrientation:AVCaptureVideoOrientationPortrait];

}

私の悪い:)

于 2012-06-24T09:27:29.780 に答える