Reputation:
I use AVMutableComposition
to perform a scaleTimeRange operation on an AVAsset
.
Everytime time the timeRange is scaled (i.e. slow motion is done on the video), I have to export it using AVExportSession
.
Q) I was wondering if there is a lighter way to preview the asset whenever I perform scaleTimeRange
, instead of having to export the Asset everytime to view changes.
I read that AVPlayerItem
is helpful, but I can't understand how.
Upvotes: 1
Views: 855
Reputation: 6635
You can create an AVPlayerItem
from an AVAsset
using AVPlayerItem(asset:)
. Also, an AVMutableComposition
is an AVComposition
is an AVAsset
.
See the overview in the documentation for AVMutableComposition
. There is an example of doing exactly that: https://developer.apple.com/reference/avfoundation/avmutablecomposition
let composition: AVMutableComposition = ...
let snapshot = composition.copy()
let playerItem = AVPlayerItem(asset: snapshot)
Upvotes: 1