小编chu*_*hub的帖子

AVMutableComposition中的黑框

这个问题与AVMutableComposition - 视频资产之间的空白/黑框相关,但由于我没有使用AVAssetExportSession,因此答案不适合我的问题.

我正在使用AVMutableComposition来创建视频合成,我正在使用AVAssetReader读取它(我需要有帧数据,我不能使用AVPlayer)但我的视频块之间经常有黑框(有音频中没有明显的故障).

我创作我的作品

AVMutableCompositionTrack *compositionVideoTrack = [composition addMutableTrackWithMediaType:AVMediaTypeVideo preferredTrackID:kCMPersistentTrackID_Invalid];
AVMutableCompositionTrack *compositionAudioTrack = [composition addMutableTrackWithMediaType:AVMediaTypeAudio preferredTrackID:kCMPersistentTrackID_Invalid];

NSMutableArray* durationList = [NSMutableArray array];
NSMutableArray* videoList= [NSMutableArray array];
NSMutableArray* audioList= [NSMutableArray array];

for (NSInteger i = 0; i < [clips count]; i++)
{
    AVURLAsset *myasset = [clips objectAtIndex:i];
    AVAssetTrack *clipVideoTrack = [[myasset tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0];
    [videoList addObject:clipVideoTrack];

    AVAssetTrack *clipAudioTrack = [[myasset tracksWithMediaType:AVMediaTypeAudio] objectAtIndex:0];
    [audioList addObject:clipAudioTrack];

    CMTime clipDuration = [myasset duration];
    CMTimeRange clipRange = CMTimeRangeMake(kCMTimeZero, clipDuration);
    [durationList addObject:[NSValue valueWithCMTimeRange:clipRange]];
}

[compositionVideoTrack insertTimeRanges:durationList …
Run Code Online (Sandbox Code Playgroud)

avfoundation ios avmutablecomposition

7
推荐指数
2
解决办法
3599
查看次数

标签 统计

avfoundation ×1

avmutablecomposition ×1

ios ×1