此問題與AVMutableComposition - Blank/Black frame between videos assets完全相關,但由於我沒有使用AVAssetExportSession,所以答案不適合我的問題。AVMutableComposition中的黑色框架
我正在使用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 ofTracks:videoList atTime:kCMTimeZero error:nil];
[compositionAudioTrack insertTimeRanges:durationList ofTracks:audioList atTime:kCMTimeZero error:nil];
我也試圖在我的作文手動插入每個軌道,但我也有同樣的現象。
由於
您是否曾經解決過這個問題?我遇到了類似的問題。 – elprl 2013-08-06 21:48:19
@elprl我看了一下我的代碼,它保持幾乎相同。我認爲我們通過調整(關鍵幀間隔,幀率,...)視頻格式輸入(我們可以控制它)來「解決」問題。那是很久以前的事了,我不能肯定地說,參數改善了這種情況。 – chub 2013-10-10 08:21:22