将ffmpeg添加到我们的Xcode项目 [英] Adding ffmpeg to our Xcode project

查看:318
本文介绍了将ffmpeg添加到我们的Xcode项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经编译了ffmpeg库,并成功在文件夹中创建了许多文件.

I have compiled the ffmpeg library and it was successfully created many files inside my folder.

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

Now I need to implement the same in my Xcode project. What is the best way for adding to my project.

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

I wish to create one framework but what files I need to add?

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

I have many .c files and .a files available after compilation.

推荐答案

过去,我已经成功使用

In the past I've successfully used this build script to integrate ffmpeg.

除非另有说明,否则以下图形说明可用于Objective-C和Swift项目.

The pictorial instructions that follow work for both Objective-C and Swift projects, unless otherwise noted.

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

As a side note, you should make sure ffmpeg is the correct tool for the job. AVFoundation and VideoToolBox are both very powerful tools that Apple provides for doing many video operations.

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

For late 2018, get the folder from the kewlbear repo which will appear as in the below image, however, there is an additional file build-ffmpeg-iOS-framework.sh. In terminal, cd to that folder. With the current version, you must run build-ffmpeg-iOS-framework.sh , not build-ffmpeg.sh to follow the following tutorial:

(通过从查找器中拖放)

(by dragging and dropping from finder)

#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简单示例:

Objective-C simple example:

#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

在Swift中:

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

这篇关于将ffmpeg添加到我们的Xcode项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆