ios - FFMPEG 将 .avi 转换为可播放的 iOS 电影 mp4

标签 ios objective-c video ffmpeg

我正在尝试将 h264 编码的baseline4.0 avi 文件转换为使用baseline3 编码的新h264 mpeg 文件。

由于baseline4.0(我认为?),文件原始文件无法在任何iOS设备上播放

我在这里使用这个包装类https://github.com/OpenWatch/FFmpegWrapper

但实际上我不知道如何设置基线。我可以转换为mpeg4,但似乎每次都默认为baseline4.0。

我尝试在 AVCodecContext 上设置它

AVCodecContext *outputCodecContext = outputStream->codec;
outputCodecContext->level = 31;
outputCodecContext->profile = FF_PROFILE_H264_BASELINE;

但这没有效果。

也许任何人都有线索,或者有更好的 FFMPEGWrapper。

原始视频的规范: original video

最佳答案

首先看一下this网站了解哪些苹果设备支持什么:

  • Encode video using H.264 compression

    • H.264 Baseline 3.0: All devices
    • H.264 Baseline 3.1: iPhone 3G and later, and iPod touch 2nd generation and later.
    • H.264 Main profile 3.1: iPad (all versions), Apple TV 2 and later, and iPhone 4 and later.
    • H.264 Main Profile 4.0: Apple TV 3 and later, iPad 2 and later, and iPhone 4S and later.
    • H.264 High Profile 4.0: Apple TV 3 and later, iPad 2 and later, and iPhone 4S and later.
    • H.264 High Profile 4.1: iPad 2 and later and iPhone 4S and later.

每个配置文件末尾的数字不是配置文件的版本!它是一个级别。这意味着如果您想支持所有设备,您应该坚持使用 Baseline 配置文件和 Level 3.0。

我不知道这个包装器的东西,但使用简单的 ffmpeg 你会使用这个选项:

-profile:v baseline -level 3.0

编辑:

抱歉,我没有注意到您已经设置了级别(可能是以正确的方式设置的)。但这里还有一个提示。请注意FFmpegWrapperinit 中对av_register_all()avcodec_register_all() 的调用。 。是否可以先初始化包装器,然后更改 AVCodecContext

关于ios - FFMPEG 将 .avi 转换为可播放的 iOS 电影 mp4,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34675983/

相关文章:

ios - 自动 AirPrint IOS

ios - UITableViewCell imageview 滚动时消失

android - 如何在Android中播放RTSP视频?

android - YouTube视频无法在WebView中播放

objective-c - 你认为什么叫做 "helper method"?

c# - 缩略图视频 C#

ios - UILabel 根据文字大小自动调整大小

ios - 为什么我在 Storyboard tableViewHeader 中的 View 在视觉上错位了?

iphone - 从 MapView 移除 MKAnnotation

ios - NavigationBar 没有完全隐藏