iOS-FFmpeg-从音频和图像文件合成视频

时间:2019-04-22 16:03:54

标签: ios audio ffmpeg video-streaming video-processing

我正在使用FFmpeg库进行视频处理的iOS项目中工作。而且我有一个任务,可以从音频文件和一组图像文件中合成视频。 有没有经历过类似任务的人? 请帮帮我!

1 个答案:

答案 0 :(得分:0)

您可以使用SwiftVideoGenerator 使用Cocoapods安装SwiftVideoGenerator,您需要导入模块:

import SwiftVideoGenerator

通过多个图像和一个音频创建视频

if let audioURL1 = Bundle.main.url(forResource: Audio1, withExtension: Mp3Extension) {
  LoadingView.lockView()

  VideoGenerator.current.fileName = MultipleSingleMovieFileName
  VideoGenerator.current.shouldOptimiseImageForVideo = true

  VideoGenerator.current.generate(withImages: [#imageLiteral(resourceName: "image1"), #imageLiteral(resourceName: "image2"), #imageLiteral(resourceName: "image3"), #imageLiteral(resourceName: "image4")], andAudios: [audioURL1], andType: .singleAudioMultipleImage, { (progress) in
    print(progress)
  }, success: { (url) in
    LoadingView.unlockView()
    print(url)
    self.createAlertView(message: self.FnishedMultipleVideoGeneration)
  }, failure: { (error) in
    LoadingView.unlockView()
    print(error)
    self.createAlertView(message: error.localizedDescription)
  })
} else {
  self.createAlertView(message: MissingAudioFiles)
}

供参考访问:https://github.com/dev-labs-bg/swift-video-generator