2010-12-03 12 views
1

私は、録画中に私のビューを表示しながら、その上にビューを置いてビデオを録画しましたが、私はそれを保存して見てみると、ビューは表示されません。ビデオをカスタマイズする

誰でもこの問題を解決するのに手伝ってもらえますか?

ありがとうございます。

+1

より詳細にあなたが持っている問題を説明し、および/またはいくつかのコードを投稿してください。それが私たちの助けになります。 – Stunner

答えて

1

私はそれがそれほど簡単ではないと恐れています。実際には、AVCaptureSessionクラスを使用して個々のフレームをキャプチャする必要があります。次に、イメージをキャプチャするときにオーバーレイされたビューをイメージに合成してから、そのコンポジットをAVCaptureDeviceにフィードできます。

かなり複雑です。ここでは、始めるためにキャプチャを設定するためのいくつかのコードです:

// Create and configure a capture session and start it running 

- (無効)setupCaptureSession { NSError *エラー= nilは、

// Create the session 
session = [[AVCaptureSession alloc] init]; // note we never release this...leak? 

// Configure the session to produce lower resolution video frames, if your 
// processing algorithm can cope. We'll specify medium quality for the 
// chosen device. 
session.sessionPreset = AVCaptureSessionPresetLow; // adjust this! AVCaptureSessionPresetLow 

// Find a suitable AVCaptureDevice 
AVCaptureDevice *device = [AVCaptureDevice 
          defaultDeviceWithMediaType:AVMediaTypeVideo]; 

// Create a device input with the device and add it to the session. 
AVCaptureDeviceInput *input = [AVCaptureDeviceInput deviceInputWithDevice:device 
                    error:&error]; 
if (!input) { 
    // Handling the error appropriately. 
    NSLog(@"Yikes, null input"); 
} 
[session addInput:input]; 

// Create a VideoDataOutput and add it to the session 
AVCaptureVideoDataOutput *output = [[[AVCaptureVideoDataOutput alloc] init] autorelease]; 
output.alwaysDiscardsLateVideoFrames = YES; // cribbed this from somewhere -- seems related to our becoming unrepsonsive 

[session addOutput:output]; 

if (!output) { 
    // Handling the error appropriately. 
    NSLog(@"ERROROROROR"); 
} 

// Configure your output. 
dispatch_queue_t queue = dispatch_queue_create("myQueue", NULL); 
[output setSampleBufferDelegate:self queue:queue]; 
dispatch_release(queue); 

// Specify the pixel format 

// kCVPixelFormatType_32RGBA or kCVPixelFormatType_32BGRA 
output.videoSettings = 
[NSDictionary dictionaryWithObject: 
[NSNumber numberWithInt:kCVPixelFormatType_32BGRA] 
          forKey:(id)kCVPixelBufferPixelFormatTypeKey]; 


// If you wish to cap the frame rate to a known value, such as 15 fps, set 
// minFrameDuration. 
output.minFrameDuration = CMTimeMake(1, VIDEO_CAPTURE_FRAMERATE); // WATCH THIS! 

NSNotificationCenter *notify = [NSNotificationCenter defaultCenter]; 
[notify addObserver: self selector: @selector(onVideoError:) name: AVCaptureSessionRuntimeErrorNotification object: session]; 
[notify addObserver: self selector: @selector(onVideoInterrupted:) name: AVCaptureSessionWasInterruptedNotification object: session]; 
[notify addObserver: self selector: @selector(onVideoEnded:) name: AVCaptureSessionInterruptionEndedNotification object: session]; 
[notify addObserver: self selector: @selector(onVideoDidStopRunning:) name: AVCaptureSessionDidStopRunningNotification object: session]; 
[notify addObserver: self selector: @selector(onVideoStart:) name: AVCaptureSessionDidStartRunningNotification object: session]; 

}

関連する問題