How do I add a still image to an AVComposition?

后端 未结 2 681
小蘑菇
小蘑菇 2021-01-31 22:16

I have an AVMutableComposition with a video track and I would like to add a still image into the video track, to be displayed for some given time. The still image i

相关标签:
2条回答
  • 2021-01-31 22:50

    I also need still images in my composition. My line of thinking is a little different. Insert on-the-fly movies of black in place of when images should be appearing (possibly one such video would suffice). Add a dictionary reference to each such insert, linking composition time-ranges to bona-fide desired images. When the correct time range arrives in my full-time custom compositor, pull out the desired image and paint that into the output pixel buffer, ignoring the incoming black frames from the composition. I think that'd be another way of doing it.

    0 讨论(0)
  • 2021-01-31 22:54

    OK. There’s a great video called Editing Media with AV Foundation from WWDC that explains a lot. You can’t insert images right to the AVComposition timeline, at least I did not find any way to do that. But when exporting or playing an asset you can refer to an AVVideoComposition. That’s maybe not a perfect name for the class, since it allows you to mix between various video tracks in the asset, very much like AVAudioMix does for audio. And the AVVideoComposition has an animationTool property that lets you throw Core Animation layers (CALayer) into the mix. CALayer has a contents property that can be assigned a CGImageRef. Does not help in my case, might help somebody else.

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