Any way to have a real-time preview of AVMutableComposition? If no, how does Final Cut Pro does it?

195 views Asked by At

is it possible to have a real-time preview of AVMutableComposition which has some layer instructions applied to its assets?

The only class I found that connects AVMutableComposition with AVVideoComposition (holding instructions) is AVExportSession. Does it mean I must export it first to play a preview?

If so, how does apps like Final Cut Pro serve real-time preview when I edit part of the video. Do they cut the whole video into multiple chunks, export what has changed and keep change of everything else?

This sounds like a difficult problem - is there any library that would help in cutting video into small chunks to export and keeping an eye on cache invalidation?

Cheers, M.

2

There are 2 answers

1
Shehata Gamal On

There is no real time preview with AVMutableComposition , they may create a time slot for every change and manage it's visibility when you change the slider below

1
swngcobo On

I don't know if this is still relevant but you can always extract each frame from the video, manipulate it accordingly then render it to the screen.

If its from AVCaptureSession you can get CMSampleBuffer from the callbacks, if it's a file I think AVReader is your best bet then you can use either CoreImage or Metal to manipulate the frames and render them in real-time.