tanersener / mobile-ffmpeg

FFmpeg for Android, iOS and tvOS. Not maintained anymore. Superseded by FFmpegKit.
https://tanersener.github.io/mobile-ffmpeg
GNU General Public License v3.0
3.85k stars 787 forks source link

How to convert mkv video to mp4 in swift? #686

Closed arlovip closed 3 years ago

arlovip commented 3 years ago

Description

I install mobile-ffmpeg-min via CocoaPods in my swift project. I want to convert mkv format video to mp4 video and then save to photo library.

Installing mobile-ffmpeg-min (4.3.1)

code snippets:

  let mkvPath = NSHomeDirectory() + "/Documents/recordvideo.mkv"
  let outputMp4 = NSHomeDirectory() + "/Documents/recordvideo.mp4"
  if FileManager.default.fileExists(atPath: mkvPath) {
          MobileFFmpeg.execute("-i \(mkvPath) -codec copy \(outputMp4)")
  }

Expected behavior Convert mkv to mp4 as expected.

Current behavior App Crash when converting video.

Screenshots

screenshot

Logs

See screenshot.

Environment