2017-08-10 63 views
1

我编译了ffmpeg库,并成功在我的文件夹中创建了许多文件。将ffmpeg添加到我的XCode项目中

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

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

我有许多.c文件和编译后可用的.a文件。

回答

2

在过去,我已成功使用this build script来整合ffmpeg。

除非另有说明,否则后面的Objective-C和Swift项目的图形说明均适用。

作为一个方面说明,你应该确保ffmpeg是工作的正确工具。 AVFoundation和VideoToolBox都是Apple提供的用于执行许多视频操作的非常强大的工具。

一旦执行该脚本,你必须将下列文件:

enter image description here

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

enter image description here

添加文件到您的项目:

(通过拖放从发现者) enter image description here

通过这些设置:

enter image description here

添加包括目录到你的头:

enter image description here

链接所需的库:

enter image description here

添加标题到桥接报头(斯威夫特只):

#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 
    } 
} 
+0

是的,这是什么我已经习惯编译...我需要知道的是将编译的文件添加到xcode – Saranjith

+0

@Saranjith你使用的是swift还是objective c? –

+0

即时通讯使用目标c ..我需要这个ffmpeg,因为我需要播放像视频0129 – Saranjith