/// 视频添加背景音乐
/// - Parameters:
/// - videoURL: 视频文件URL
/// - audioURL: 音频文件URL
/// - startTime: 音频开始时间
/// - endTime: 音频结束时间
/// - isOriginal: 是否保留视频原音
/// - oriVolume: 视频原音音量
/// - newVolume: 新增背景音乐音量
/// - outputURL: 视频输出文件地址
/// - completion: 完成回掉
static func addBackgroundMusic(videoURL : URL, audioURL : URL, startTime : Double, endTime : Double, isOriginal : Bool = true, oriVolume : Float, newVolume : Float, outputURL : String, completion : @escaping (_ success : Bool) -> Void) {
if FileManager.default.fileExists(atPath: outputURL) {
do {
try FileManager.default.removeItem(atPath: outputURL)
} catch {
logger(item: "addBackgroundMusic remove exit file error")
}
}
do {
//导出路径
let outputFileURL = URL.init(fileURLWithPath: outputURL)
let nextClipStartTime = CMTime.zero
//创建可变的音频视频组合
ios AVFoundation框架给视频添加背景音乐的方法
最新推荐文章于 2025-04-17 10:04:57 发布