Skip to main content

ios - Access Images and Audio with AVFoundation -


i using avfoundation accessing images , audio making video. problem when adding device audio like.

avcapturedevice *audiodevice = [avcapturedevice defaultdevicewithmediatype: avmediatypeaudio]; avcapturedeviceinput * microphone_input = [avcapturedeviceinput deviceinputwithdevice:audiodevice error:nil]; avcaptureaudiodataoutput * audio_output = [[avcaptureaudiodataoutput alloc] init]; [self.capturesession2 addinput:microphone_input]; [self.capturesession2 addoutput:audio_output]; dispatch_queue_t queue2; queue2 = dispatch_queue_create("audio", null); [audio_output setsamplebufferdelegate:self queue:queue2]; dispatch_release(queue2); 

and camera images.

avcapturedevice *cameradevice = [avcapturedevice defaultdevicewithmediatype:avmediatypevideo]; //putting on input. avcapturedeviceinput *captureinput = [avcapturedeviceinput deviceinputwithdevice:cameradevice error:nil]; //selecting output. avcapturevideodataoutput *captureoutput = [[avcapturevideodataoutput alloc] init]; [self.capturesession addinput:captureinput]; [self.capturesession addoutput:captureoutput]; dispatch_queue_t queue; queue = dispatch_queue_create("cameraqueue", 0); [captureoutput setsamplebufferdelegate:self queue:queue]; dispatch_release(queue); 

and after getting raw data through delegates

- (void)captureoutput:(avcaptureoutput *)captureoutput didoutputsamplebuffer:(cmsamplebufferref)samplebuffer fromconnection:(avcaptureconnection *)connection { if ([captureoutput iskindofclass:[avcaptureaudiodataoutput class]]) [self sendaudeoraw:samplebuffer]; if ([captureoutput iskindofclass:[avcapturevideodataoutput class]]) [self sendvideoraw:samplebuffer];} 

the speed of getting images raw data slow around 2 images per second. how can improve because looking around 10-12 images/second. please help

ios - access images , audio avfoundation - stack overflow

learn, share, build

each month, on 50 million developers come stack overflow learn, share knowledge, , build careers.

join world’s largest developer community.

sign up

i using avfoundation accessing images , audio making video. problem when adding device audio like.

avcapturedevice *audiodevice = [avcapturedevice defaultdevicewithmediatype: avmediatypeaudio]; avcapturedeviceinput * microphone_input = [avcapturedeviceinput deviceinputwithdevice:audiodevice error:nil]; avcaptureaudiodataoutput * audio_output = [[avcaptureaudiodataoutput alloc] init]; [self.capturesession2 addinput:microphone_input]; [self.capturesession2 addoutput:audio_output]; dispatch_queue_t queue2; queue2 = dispatch_queue_create("audio", null); [audio_output setsamplebufferdelegate:self queue:queue2]; dispatch_release(queue2); 

and camera images.

avcapturedevice *cameradevice = [avcapturedevice defaultdevicewithmediatype:avmediatypevideo]; //putting on input. avcapturedeviceinput *captureinput = [avcapturedeviceinput deviceinputwithdevice:cameradevice error:nil]; //selecting output. avcapturevideodataoutput *captureoutput = [[avcapturevideodataoutput alloc] init]; [self.capturesession addinput:captureinput]; [self.capturesession addoutput:captureoutput]; dispatch_queue_t queue; queue = dispatch_queue_create("cameraqueue", 0); [captureoutput setsamplebufferdelegate:self queue:queue]; dispatch_release(queue); 

and after getting raw data through delegates

- (void)captureoutput:(avcaptureoutput *)captureoutput didoutputsamplebuffer:(cmsamplebufferref)samplebuffer fromconnection:(avcaptureconnection *)connection { if ([captureoutput iskindofclass:[avcaptureaudiodataoutput class]]) [self sendaudeoraw:samplebuffer]; if ([captureoutput iskindofclass:[avcapturevideodataoutput class]]) [self sendvideoraw:samplebuffer];} 

the speed of getting images raw data slow around 2 images per second. how can improve because looking around 10-12 images/second. please help

share|improve question
    
what [self sendvideoraw:samplebuffer]? – steve mcfarlin jul 7 '12 @ 19:12
    
also, in captureoutput code compare pointers rather using iskindofclass. e.g. if(captureoutput == audio_output). have careful iskindofclass. can return may not expecting. occurs container classes. see post discussion. 1 last think. not need use 2 different capture sessions audio , video. both av io classes can added same session. – steve mcfarlin jul 7 '12 @ 19:23
    
@stevemcfarlin separating audio , image raw data processing. – loading username..... jul 9 '12 @ 5:38
    
@stevemcfarlin main problem getting video frames slow delegate function called 2 times in second , looking around 8-10 times in single second. – loading username..... jul 9 '12 @ 5:44
    
username - strange. should able achieve 30fps pure capture. reason asked [self sendvideoraw:samplebuffer] thought perhaps code blocking capture queue long enough allow 2fps. if uncomment code fps get. i'll assume still 2fps. may configuration issue, without more code can not tell. might take @ avcamdemo project apple. – steve mcfarlin jul 10 '12 @ 17:57

your answer

 
discard

posting answer, agree privacy policy , terms of service.

browse other questions tagged or ask own question.


Comments

Popular posts from this blog

javascript - backbone.js Collection.add() doesn't `construct` (`initialize`) an object -

php - Get uncommon values from two or more arrays -

Adding duplicate array rows in Php -