当音频持续时间小于视频持续时间时合并 audio/video

Merge audio/video when audio duration is less than video duration

我只合并一个 audio/video 文件。问题是,我的视频文件是 40 秒,音频文件是 28 秒。因此,对于剩余的 12 (40 - 28) 秒——我想从 0 秒开始重复剩余部分的音频。我该怎么做?有直接的方法吗?

P.S。我正在为此使用 AVComposition。来自 here.

的代码

首先计算视频和音频的时间,我猜你能做到。如果音频小于视频,请使用 How to trim audio file in iPhone?. Do follow the same and then merge the audio files Combine two audio files into one in objective c 中提到的代码裁剪音频,然后执行您想要的操作。