I have compiled the ffmpeg library and it was successfully created many files inside my folder.
Now I need to implement the same in my Xcode project. What is the best wa
In the past I've successfully used this build script to integrate ffmpeg.
The pictorial instructions that follow work for both Objective-C and Swift projects, unless otherwise noted.
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.
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 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
And in 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
}
}