Converting an AudioBufferList to a CMSampleBuffer Produces Unexpected Results

前端 未结 1 996
予麋鹿
予麋鹿 2021-01-19 06:38

I\'m trying to convert an AudioBufferList that I get from an Audio Unit into a CMSampleBuffer that I can pass into an AVAssetWriter to

相关标签:
1条回答
  • 2021-01-19 07:30

    It turns out that the fact that the sample size was coming back as 0 was a red herring. Once I cleaned up a few things--notably, I set the timestamp correctly, like so:

    uint64_t timeNS = (uint64_t)(hostTime * _hostTimeToNSFactor);
    CMTime presentationTime = CMTimeMake(timeNS, 1000000000);
    CMSampleTimingInfo timing = { CMTimeMake(1, 48000), presentationTime, kCMTimeInvalid };
    

    recording started working.

    So, in the event that someone else is thrown off by the reportedly 0 sample buffer size, be aware that this is OK, at least in the case in which you're feeding the data into an AVAssetWriter.

    0 讨论(0)
提交回复
热议问题