I'm played videos using AVPlayer,
AVPlayerItem
and AVVideoComposition
.
Select video files from photo album or file and create AVVideoCompositionInstructionProtocol
.
Set the desired CMTimeRange for each file and create an AVVideoCompositionInstructionProtocol
. In addition, instructions are included using AVMutableVideoComposition,
and AVPlayerItem
is playing using composition.
It plays well in normal situations, but the AVPlayer does not play when using about 30 video files. There is no response when you press play and sometimes an AVFoundationErrorDomainCode "-11819"
error occurs.
Why is this happen? I would appreciate it if you could let me know what I need to do to solve this.
I found the answer. The reason for the non-playback or AVFoundation error was that too many AVVMutableCompositionTracks were used.
I used 30 video assets, and whenever I got tracks from asset, I always used addMutableTrack(withMediaType mediaType:, preferredTrackID:) -> AVMutableCompositionTrack?
.
Which means more than 30 compositionTracks are created.
We have confirmed that these generated tracks cause performance degradation and playback errors.
Assets with essentially non-overlapping globalTimeRange could solve this problem by using the same compositionTrack.
I hope it helps people who have the same phenomenon as me.