AVAssetReader Seeking

后端 未结 2 1217
猫巷女王i
猫巷女王i 2020-12-30 15:12

I am in need of seeking around an audio file and pull out chunks. I am trying to use the AVAssetReader. The bug I am seeing is if I read the audio over a period of time from

2条回答
  •  暖寄归人
    2020-12-30 15:45

    In my own experience seeking with

    assetReader.timeRange = CMTimeRangeMake(CMTimeMake(sample, sample_rate), kCMTimePositiveInfinity)
    

    works perfectly. There's no precision problem with the seeking.

    What you may encounter is the fade-in issue : in fact AVAssetReader seems to fade in the first 1024 samples (maybe a little more). I fixed it by reading 1024 samples before the position I really want to read, then skip that 1024 samples.

提交回复
热议问题