2

私は、AVMutableComposition を使用していくつかの基本的なビデオ構成に取り組んでいます。現在、テキスト レイヤー (CATextLayer) を含むビデオ レイヤー (AVMutableVideoComposition) です。

すべて問題ないように見えますが、「AVMutableComposition exportAsynchronouslyWithCompletionHandler」を介してエクスポートすると、オフになって完了しますが、次のエラーが返されます。

CoreAnimation: warning, deleted thread with uncommitted CATransaction; created by:
0   QuartzCore                          0x00007fff8a106959 _ZN2CA11Transaction4pushEv + 219
1   QuartzCore                          0x00007fff8a106531 _ZN2CA11Transaction15ensure_implicitEv + 273
2   QuartzCore                          0x00007fff8a10d66f _ZN2CA5Layer13thread_flags_EPNS_11TransactionE + 37
3   QuartzCore                          0x00007fff8a10d5a7 _ZN2CA5Layer4markEPNS_11TransactionEjj + 79
4   QuartzCore                          0x00007fff8a112cac _ZN2CA5Layer27contents_visibility_changedEPNS_11TransactionEb + 216
5   QuartzCore                          0x00007fff8a112b65 _ZN2CA5Layer12mark_visibleEPNS_11TransactionEb + 261
6   QuartzCore                          0x00007fff8a112b26 _ZN2CA5Layer12mark_visibleEPNS_11TransactionEb + 198
7   QuartzCore                          0x00007fff8a112b26 _ZN2CA5Layer12mark_visibleEPNS_11TransactionEb + 198
8   QuartzCore                          0x00007fff8a1128d1 _ZN2CA5Layer11set_visibleEj + 335
9   QuartzCore                          0x00007fff8a1126b9 _ZN2CA7Context9set_layerEPKv + 75
10  MediaToolbox                        0x00007fff857f155b FigCoreAnimationRendererInvalidate + 108
11  CoreFoundation                      0x00007fff8ec763df CFRelease + 511
12  MediaToolbox                        0x00007fff857d3a6b FigVideoCompositionProcessorInvalidate + 675
13  MediaToolbox                        0x00007fff85791341 FigAssetWriterCreateWithURL + 18573
14  MediaToolbox                        0x00007fff85791f7b FigAssetWriterCreateWithURL + 21703
15  CoreMediaAuthoringCrunchers         0x00000001046e2b99 AssetAudioSourcer_CreateInstance + 3865

次の行をコメントアウトすると、これはなくなりますが、CATextLayer はレンダリングされません。

videoComposition.animationTool = [AVVideoCompositionCoreAnimationTool videoCompositionCoreAnimationToolWithPostProcessingAsVideoLayer:videoLayer inLayer:parentLayer];

誰か考えはありますか?

アダム

4

1 に答える 1

1

メイン スレッドで UI 描画が行われるようにする必要があります。コメントアウトした行はおそらく内部で何らかの描画を行うため、このコードがメイン スレッドで実行されるようにする必要があります。これを行ういくつかの方法は、関数dispatch_async()またはメソッドperformSelectorOnMainThread:withObject:waitUntilDone:またはperformSelectorOnMainThread:withObject:waitUntilDone:modes:

- (void) someMethod
{
    // You may need to load a container object to pass as myCustomData whose
    // contents you then access in myCustomDrawing: if the data isn't accessible
    // as instance data.

    [...]

    // Perform all drawing/UI updates on the main thread.
    [self performSelectorOnMainThread:@selector(myCustomDrawing:)
                           withObject:myCustomData
                        waitUntilDone:YES];

    [...]
}

- (void) myCustomDrawing:(id)myCustomData
{
    // Perform any drawing/UI updates here.
    videoComposition.animationTool = [AVVideoCompositionCoreAnimationTool videoCompositionCoreAnimationToolWithPostProcessingAsVideoLayer:videoLayer
                                                                                                                                  inLayer:parentLayer];
}

と の違いに関する関連記事については、メイン キューでの performSelectorOnMainThread と dispatch_async の違いは何ですか?dispatch_async()performSelectorOnMainThread:withObjects:waitUntilDone:参照してください。

于 2013-11-05T01:14:44.803 に答える