将AVI视频转换为MP4视频(用于在iOS上播放)
我有一个视频文件,它是由第三方库生成的,它正在从远程摄像机录制视频。这个API以AVI格式@4fps生成一个视频文件,我举的例子是352x288px 我一直在尝试将视频转换为在iOS中播放。我知道iOS只支持有限范围的视频格式,我一直在努力让任何东西都能正常工作 我试着使用以下基于 和其他几种变体,但都失败了。上述代码在以下情况下失败:将AVI视频转换为MP4视频(用于在iOS上播放),ios,swift,avfoundation,avassetexportsession,Ios,Swift,Avfoundation,Avassetexportsession,我有一个视频文件,它是由第三方库生成的,它正在从远程摄像机录制视频。这个API以AVI格式@4fps生成一个视频文件,我举的例子是352x288px 我一直在尝试将视频转换为在iOS中播放。我知道iOS只支持有限范围的视频格式,我一直在努力让任何东西都能正常工作 我试着使用以下基于 和其他几种变体,但都失败了。上述代码在以下情况下失败: Error = Optional(Error Domain=AVFoundationErrorDomain Code=-11822 "Cannot Open"
Error = Optional(Error Domain=AVFoundationErrorDomain Code=-11822 "Cannot Open" UserInfo={NSLocalizedFailureReason=This media format is not supported., NSLocalizedDescription=Cannot Open, NSUnderlyingError=0x283244bd0 {Error Domain=NSOSStatusErrorDomain Code=-16976 "(null)"}})
因此,我假设要么我没有向转换器提供正确的选项/建议,要么只是AVFoundation不支持这种类型的操作
以下是MediaInfo生成的信息
General
Complete name : /Users/swhitehead/Downloads/DVR8-4580V, Channel 8.avi
Format : AVI
Format/Info : Audio Video Interleave
File size : 361 KiB
Duration : 28s 500ms
Overall bit rate : 104 Kbps
Video
ID : 0
Format : AVC
Format/Info : Advanced Video Codec
Format profile : Baseline@L2
Format settings : 1 Ref Frames
Format settings, CABAC : No
Format settings, ReFrames : 1 frame
Format settings, GOP : M=1, N=4
Codec ID : H264
Duration : 28s 500ms
Bit rate : 101 Kbps
Width : 352 pixels
Height : 288 pixels
Display aspect ratio : 1.222
Frame rate : 4.000 fps
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.249
Stream size : 351 KiB (97%)
问题
有没有什么方法可以将这种类型的视频文件转换为支持mp4格式,并由iOS播放
注:我理解这可能是一个广泛的问题,因为可能不存在简单的解决方案,但即使是一些建议或提示也会很感激,因为这会让我发疯
当我在没有GOP格式设置的情况下使用视频时,它可以成功导出。@rmaddy我理解这在技术上不是一个基于objc的问题,但如果它能帮助我找到问题的解决方案,我将接受基于objc的答案
General
Complete name : /Users/swhitehead/Downloads/DVR8-4580V, Channel 8.avi
Format : AVI
Format/Info : Audio Video Interleave
File size : 361 KiB
Duration : 28s 500ms
Overall bit rate : 104 Kbps
Video
ID : 0
Format : AVC
Format/Info : Advanced Video Codec
Format profile : Baseline@L2
Format settings : 1 Ref Frames
Format settings, CABAC : No
Format settings, ReFrames : 1 frame
Format settings, GOP : M=1, N=4
Codec ID : H264
Duration : 28s 500ms
Bit rate : 101 Kbps
Width : 352 pixels
Height : 288 pixels
Display aspect ratio : 1.222
Frame rate : 4.000 fps
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.249
Stream size : 351 KiB (97%)