简体   繁体   English

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

[英]iOS-FFmpeg-Compose video from audio and image files

I am working in a iOS project that using FFmpeg library for video processing. 我正在使用FFmpeg库进行视频处理的iOS项目中工作。 And I got a task for composing video from audio file and a set of image files. 我得到了一个从音频文件和一组图像文件组成视频的任务。 Have anyone experienced on similar task? 有没有人经历过类似的任务? Help me please! 请帮帮我!

You can use SwiftVideoGenerator use Cocoapods to install SwiftVideoGenerator , you need to import the module: 你可以使用SwiftVideoGenerator使用Cocoapods来安装SwiftVideoGenerator ,你需要导入模块:

import SwiftVideoGenerator

Create a video from multiple images and a single audio 从多个图像和单个音频创建视频

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)
}

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM