AVMutableComposition - Blank/Black frame between videos assets

前端 未结 2 1984
攒了一身酷
攒了一身酷 2021-01-01 04:29

I\'m currently trying to put 5 videos back to back using AVMutableComposition like so:

[mixComposition insertTimeRange:CMTimeRangeMake(kCMTimeZero, asset1.du         


        
2条回答
  •  耶瑟儿~
    2021-01-01 04:53

    I just met the same problem. Turn out the solution is using AVMutableCompositionTrack and compositing the video tracks, something like this.

    AVMutableCompositionTrack * videoTrack = [composition addMutableTrackWithMediaType:AVMediaTypeVideo preferredTrackID:kCMPersistentTrackID_Invalid];
    
    [videoTrack insertTimeRange:CMTimeRangeMake(kCMTimeZero, asset.duration) ofTrack:[[asset tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0] atTime:composition.duration error:&error];
    

    For the audio part I think you must add a separate track with AVMediaTypeAudio type.

提交回复
热议问题