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

问题描述 投票:0回答:1

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

ios audio ffmpeg video-streaming video-processing
1个回答
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

© www.soinside.com 2019 - 2024. All rights reserved.