AVMutableComposition - 视频资产之间的空白/黑框 [英] AVMutableComposition - Blank/Black frame between videos assets

查看:122
本文介绍了AVMutableComposition - 视频资产之间的空白/黑框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在尝试使用AVMutableComposition背靠背放置5个视频,如下所示:

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

[mixComposition insertTimeRange:CMTimeRangeMake(kCMTimeZero, asset1.duration) ofAsset:asset1 atTime:[mixComposition duration] error:nil];
[mixComposition insertTimeRange:CMTimeRangeMake(kCMTimeZero, asset2.duration) ofAsset:asset2 atTime:[mixComposition duration] error:nil];
[mixComposition insertTimeRange:CMTimeRangeMake(kCMTimeZero, asset3.duration) ofAsset:asset3 atTime:[mixComposition duration] error:nil];
[mixComposition insertTimeRange:CMTimeRangeMake(kCMTimeZero, asset4.duration) ofAsset:asset4 atTime:[mixComposition duration] error:nil];
[mixComposition insertTimeRange:CMTimeRangeMake(kCMTimeZero, asset5.duration) ofAsset:asset5 atTime:[mixComposition duration] error:nil];

然后我使用AVAssetExportSession导出视频,但是在我获得的视频之间有效我需要删除的空白/黑框。有没有人之前有这个问题,如果是这样你设法解决它?

I then use an AVAssetExportSession to export the video, which works however between each video I'm getting a blank/black frame which I need to remove. Has anyone had this problem before and if so did you manage to fix it?

此外,空白帧不在源视频文件中。

Also, the blank frames aren't in the source video files.

提前致谢。

推荐答案

前几天我遇到了同样的问题。

I had the same problem the other day.

如果您通过从再次使用insertTimeRange创建的其他资产中导出资产(asset1,asset2等),则情况相同。

If you got your assets(asset1, asset2, etc.) by exporting them from other asset which was created using again insertTimeRange, then it's the same case.

问题在于,当您导出使用insertTimeRange创建的资源时,导出不正确,当您附加此类视频时,它们之间会出现黑框。

The problem is that when you export assets created using insertTimeRange, the export doesn't go correct, when you attach such videos black frames appear between them.

尝试使用AVAssetExportSession的timeRange选项,并从主资源中删除所需的范围。那么您的资产将附加正确。

Try using "timeRange" option of the AVAssetExportSession, and cut the range you need from the main asset. Then your assets will attach correct.

这篇关于AVMutableComposition - 视频资产之间的空白/黑框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆