मै मैक ओएस एक्स पर वेबकैम से प्राप्त वीडियो को दर्पण करने की कोशिश कर रहा हूं। मैं वीडियो बफर प्राप्त करने के बाद मैनुअल फ्लिप/ट्रैनफॉर्म करने से बचाना चाहता हूं। इसलिए, मैं AVCaptureSession
सेटअप करना चाहता हूं जैसे कि captureOutput
AVCaptureVideoDataOutputSampleBufferDelegate
में प्राप्त वीडियो बफर AVFoundation द्वारा प्रतिबिंबित किया गया है। मैं पूर्वावलोकन परत का उपयोग नहीं करना चाहता।AVFoundation - वेबकैम से वीडियो कैसे मिरर करें - मैक ओएस एक्स
वीडियो को दर्पण करने के लिए iMac (10.8.5) पर, videoMirrored
संपत्ति सेट करने से पहले सफलतापूर्वक परीक्षण किया जाता है। लेकिन captureOutput
प्रतिनिधि में प्राप्त वीडियो बफर प्रतिबिंबित नहीं है।
नोट: आईओएस पर वीडियो मिररिंग सफल रहा, जब मैंने this SO उत्तर दिया। लेकिन यह मैक ओएस एक्स पर मदद नहीं कर रहा है।
उपयोग किया गया कोड नीचे है। इस पोस्ट के लिए त्रुटि जांच छोड़ दी गई है।
//create session
_session = [[AVCaptureSession alloc] init];
//get capture device
_device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
//create sesion input
NSError * error;
_sessionInput = [AVCaptureDeviceInput deviceInputWithDevice:_device error:&error];
//create session output
_sessionOutput = [[AVCaptureVideoDataOutput alloc] init];
[_sessionOutput setAlwaysDiscardsLateVideoFrames:YES];
[[_sessionOutput connectionWithMediaType:AVMediaTypeVideo] setEnabled:YES];
NSDictionary *videoSettings = [NSDictionary dictionaryWithObject: [NSNumber numberWithUnsignedInt:kCVPixelFormatType_32BGRA] forKey:(id)kCVPixelBufferPixelFormatTypeKey];
[_sessionOutput setVideoSettings:videoSettings];
//serial queue to process video frames
dispatch_queue_t videoOutputQueue = dispatch_queue_create("deviceeraQueue", DISPATCH_QUEUE_SERIAL);
[_sessionOutput setSampleBufferDelegate:self queue:videoOutputQueue];
//begin session configuration
[_session beginConfiguration ];
//input and output for session
if([_session canAddInput:_sessionInput]) {
[_session addInput:_sessionInput];
}
if([_session canAddOutput:_sessionOutput]) {
[_session addOutput:_sessionOutput];
}
//set video mirroring
AVCaptureConnection* avConnection = [_sessionOutput connectionWithMediaType:AVMediaTypeVideo];
if([avConnection isVideoMirroringSupported]) {
avConnection.videoMirrored = YES;
NSLog(@"Video mirroring Support: YES"); // this line is printed
} else {
NSLog(@"Video mirroring Support: NO");
}
//set session preset
[_session setSessionPreset:AVCaptureSessionPreset640x480];
[ _session commitConfiguration ];
...........
...........
- (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection
{
.........
//sampleBuffer is not mirrored video
........
कम महत्व 1 के
- हालांकि सी ++, मैं भी वीडियो को प्रतिबिंबित करने के लिए जिस तरह से OpenCV के VideoCapture कार्यान्वयन में देख कोशिश की। लेकिन, ओपनसीवी मैक से वीडियो दर्पण नहीं करता है (फ्लिप का उपयोग करता है)। बाएं libVlc/V4L है।
कम महत्व 2 के- की this 2010 WWDC सेब प्रस्तुति (3MB पीडीएफ) स्लाइड 73 में, वहाँ एक उल्लेख नहीं है कि setVideoOrientation
'AVCaptureVideoDataOutput` कनेक्शन पर समर्थित नहीं है है। लेकिन 2013 में, सेब docs अद्यतन और इस विधि का समर्थन करता है।
धन्यवाद। लेकिन सवाल में, मैंने पूर्वावलोकन परत (अनुच्छेद 1 में) – Kiran
का उपयोग करने के लिए अनिच्छा के बारे में उल्लेख किया था ओएसएक्स वीडियो का सम्मान नहीं करता है मिरर संपत्ति, शायद एक बग। एक पूर्वावलोकन परत का उपयोग करना एकमात्र तरीका है जिसे मैंने प्रभाव प्राप्त करने के लिए पाया है। – tansk1