AVAssetWriter Woes

前端 未结 2 1739
耶瑟儿~
耶瑟儿~ 2020-12-28 20:19

I\'m trying to use AVAssetWriter to write CGImages to a file to create a video from images.

I\'ve gotten this to work successfully in three different ways on the sim

2条回答
  •  悲&欢浪女
    2020-12-28 20:57

    I've found the solution to this issue.

    If you want to have AVAudioPlayer and AVAssetWriter behave correctly together, you must have and audio session category that is 'mixable'.

    You can use a category that is mixable like AVAudioSessionCategoryAmbient.

    However, I needed to use AVAudioSessionCategoryPlayAndRecord.

    You can set any category to be mixable by implementing this:

    OSStatus propertySetError = 0;
    
    UInt32 allowMixing = true;
    
    propertySetError = AudioSessionSetProperty (
                           kAudioSessionProperty_OverrideCategoryMixWithOthers,  // 1
                           sizeof (allowMixing),                                 // 2
                           &allowMixing                                          // 3
                       );
    

提交回复
热议问题