ios - Append audio samples to AVAssetWriter from streaming -


i'm using project when i'm recording video camera, audio comes streaming. audio frames not synchronised video frames. if use avassetwriter without video, recording audio frames streaming working fine. if append video , audio frames, can't hear anything.

here method convert audiodata stream cmsamplebuffer

audiostreambasicdescription monostreamformat = [self getaudiodescription];   cmformatdescriptionref format = null; osstatus status = cmaudioformatdescriptioncreate(kcfallocatordefault, &monostreamformat, 0,null, 0, null, null, &format); if (status != noerr) {     // shouldn't happen     return nil; }  cmsampletiminginfo timing = { cmtimemake(1, 44100.0), kcmtimezero, kcmtimeinvalid };   cmsamplebufferref samplebuffer = null; status = cmsamplebuffercreate(kcfallocatordefault, null, false, null, null, format, numsamples, 1, &timing, 0, null, &samplebuffer); if (status != noerr) {     // couldn't create sample alguiebuffer     nslog(@"failed create sample buffer");     cfrelease(format);     return nil; }  // add samples buffer status = cmsamplebuffersetdatabufferfromaudiobufferlist(samplebuffer,                                                         kcfallocatordefault,                                                         kcfallocatordefault,                                                         0,                                                         samples); if (status != noerr) {     nslog(@"failed add samples sample buffer");     cfrelease(samplebuffer);     cfrelease(format);     return nil; } 

i don't know if related timing. append audio frames first second of video.

is possible?

thanks

finally did this

uint64_t _hosttimetonsfactor = hosttime;  _hosttimetonsfactor *= info.numer; _hosttimetonsfactor /= info.denom;  uint64_t timens = (uint64_t)(hosttime * _hosttimetonsfactor); cmtime presentationtime = self.initialisetime;//cmtimemake(timens, 1000000000); cmsampletiminginfo timing = { cmtimemake(1, 44100), presentationtime, kcmtimeinvalid }; 

Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -