加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ios – 将ffmpeg添加到我们的Xcode项目中

发布时间:2020-12-14 19:29:41 所属栏目:百科 来源:网络整理
导读:我编译了ffmpeg库,并在我的文件夹中成功创建了许多文件. 现在我需要在我的Xcode项目中实现相同的功能.添加到项目的最佳方式是什么? 我想创建一个框架,但我需要添加哪些文件? 编译后我有很多.c文件和.a文件. 解决方法 在过去,我已成功使用 this build scrip
我编译了ffmpeg库,并在我的文件夹中成功创建了许多文件.

现在我需要在我的Xcode项目中实现相同的功能.添加到项目的最佳方式是什么?

我想创建一个框架,但我需要添加哪些文件?

编译后我有很多.c文件和.a文件.

解决方法

在过去,我已成功使用 this build script来集成ffmpeg.

除非另有说明,否则后续的图示说明适用于Objective-C和Swift项目.

作为旁注,您应该确保ffmpeg是正确的工具. AVFoundation和VideoToolBox都是Apple提供的非常强大的工具,可用于执行许多视频操作.

在2018年末,从kewlbear repo获取文件夹,如下图所示,但是,还有一个额外的文件build-ffmpeg-iOS-framework.sh.在终端中,cd到该文件夹??.对于当前版本,您必须运行build-ffmpeg-iOS-framework.sh,而不是build-ffmpeg.sh以遵循以下教程:

执行完脚本后,您将拥有以下文件:

enter image description here

将FFmpeg-iOS文件夹复制到您的项目:

enter image description here

将文件添加到项目中:

(通过从finder中拖放)

enter image description here

使用这些设置:

enter image description here

将include目录添加到标头:

enter image description here

链接所需的库:

enter image description here

将标头添加到桥接标头(仅限Swift):

#import "libavcodec/avcodec.h"
#import "libavdevice/avdevice.h"
#import "libavfilter/avfilter.h"
#import "libavformat/avformat.h"
#import "libavutil/avutil.h"
#import "libswresample/swresample.h"
#import "libswscale/swscale.h"

Objective-C简单示例:

#import "AppDelegate.h"
#import "libavformat/avformat.h"

@interface AppDelegate ()
@end

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    AVFormatContext *context = avformat_alloc_context();

    return YES;
}

@end

在斯威夫特:

import UIKit

@UIApplicationMain
class AppDelegate: UIResponder,UIApplicationDelegate {

    var window: UIWindow?


    func application(_ application: UIApplication,didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

        let context = avformat_alloc_context()

        return true
    }
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读