VideoFlint / Cabbage

A video composition framework build on top of AVFoundation. It's simple to use and easy to extend.
MIT License
1.55k stars 227 forks source link

About the text overlay, edit, drag and drop, zoom. #70

Open junnnerr opened 3 years ago

junnnerr commented 3 years ago

About the text overlay, edit, drag and drop, zoom in and out of the function, whether there is a demonstration code, or a way of thinking to achieve.

Alexey-Matjuk commented 3 years ago

There is Overlay Demo. Text should be rendered to an image and then added as overlay Everything should be implemented by yourself. And then applied to timeline.

For example: You can apply transformations to video like this:

trackItem.videoConfiguration.transform = <Your Transformation>

Or trim video:

let videoPlayableRange: ClosedRange<Double>

guard let exportSession = compositionGenerator.buildExportSession(outputURL: outputURL) else { return }
exportSession.timeRange = CMTimeRange(
            start: CMTime(
                seconds: videoDuration * videoPlayableRange.lowerBound,
                preferredTimescale: CMTimeScale(NSEC_PER_SEC)
            ),
            end: CMTime(
                seconds: videoDuration * videoPlayableRange.upperBound,
                preferredTimescale: CMTimeScale(NSEC_PER_SEC)
            )
        )
exportSession.exportAsynchronously {}