How to write a movie with video AND audio using AVAssetWriter?

后端 未结 2 787
囚心锁ツ
囚心锁ツ 2021-01-31 19:16

I want to export a movie with AVAssetWriter and can\'t figure out how to include video and audio tracks in sync. Exporting only video works fine, but when I add aud

2条回答
  •  时光取名叫无心
    2021-01-31 19:44

    It seams that assetWriterAudioInput ignores sample buffer time for audio writing. Do this way.

    1) Write video track.

    2) When done, mark it finished i.e. [videoWriterInput markAsFinished];

    3) do [assetWriter startSessionAtSourceTime:timeRangeStart];

    3) instantiate audio reader and start writing audio.

提交回复
热议问题