|
|
4 years ago | |
|---|---|---|
| .. | ||
| m4 | 5 years ago | |
| src | 4 years ago | |
| .gitignore | 4 years ago | |
| Doxyfile | 4 years ago | |
| Makefile.am | 5 years ago | |
| Makefile.in | 4 years ago | |
| README.md | 4 years ago | |
| aclocal.m4 | 4 years ago | |
| ar-lib | 4 years ago | |
| autogen.sh | 5 years ago | |
| compile | 4 years ago | |
| config.guess | 4 years ago | |
| config.sub | 4 years ago | |
| configure | 4 years ago | |
| configure.ac | 4 years ago | |
| depcomp | 4 years ago | |
| install-sh | 5 years ago | |
| libtool | 4 years ago | |
| ltmain.sh | 5 years ago | |
| missing | 4 years ago | |
README.md
FFmpegKit for iOS, macOS and tvOS
1. Features
1.1 iOS
- Supports
iOS SDK 12.1+on Main releases andiOS SDK 9.3+on LTS releases - Includes
armv7,armv7s,arm64,arm64-simulator,arm64e,i386,x86_64,x86_64-mac-catalystandarm64-mac-catalystarchitectures - Objective-C API
- Camera access
ARCenabled library- Built with
-fembed-bitcodeflag - Creates static
frameworks, staticxcframeworksand staticuniversal (fat)libraries (.a)
1.2 macOS
- Supports
macOS SDK 10.15+on Main releases andmacOS SDK 10.11+on LTS releases - Includes
arm64andx86_64architectures - Objective-C API
- Camera access
ARCenabled library- Built with
-fembed-bitcodeflag - Creates static
frameworks, staticxcframeworksand staticuniversal (fat)libraries (.a)
1.3 tvOS
- Supports
tvOS SDK 10.2+on Main releases andtvOS SDK 9.2+on LTS releases - Includes
arm64,arm64-simulatorandx86_64architectures - Objective-C API
ARCenabled library- Built with
-fembed-bitcodeflag - Creates static
frameworks, staticxcframeworksand staticuniversal (fat)libraries (.a)
2. Building
Run ios.sh/macos.sh/tvos.sh at project root directory to build ffmpeg-kit and ffmpeg static libraries for a
platform.
Optionally, use apple.sh to combine bundles created by these three scripts in a single bundle.
Please note that FFmpegKit project repository includes the source code of FFmpegKit only. ios.sh, macos.sh and
tvos.sh need network connectivity and internet access to github.com in order to download the source code of
FFmpeg and external libraries enabled.
2.1 Prerequisites
ios.sh, macos.sh and tvos.sh require the following tools and packages.
2.1.1 iOS
- Xcode 7.3.1 or later
- iOS SDK 9.3 or later
- Command Line Tools
2.1.2 macOS
- Xcode 7.3.1 or later
- macOS SDK 10.11 or later
- Command Line Tools
2.1.3 tvOS
- Xcode 7.3.1 or later
- tvOS SDK 9.2 or later
- Command Line Tools
2.1.4 Packages
Use your package manager (brew, etc.) to install the following packages.
autoconf automake libtool pkg-config curl cmake gcc gperf texinfo yasm nasm bison autogen git wget autopoint meson ninja
2.2 Options
Use --enable-<library name> flag to support additional external or system libraries and
--disable-<architecture name> to disable architectures you don't want to build.
./ios.sh --enable-fontconfig --disable-armv7
./macos.sh --enable-freetype --enable-macos-avfoundation --disable-arm64
./tv.sh --enable-dav1d --enable-libvpx --disable-arm64-simulator
Run --help to see all available build options.
2.3 LTS Binaries
Use --lts option to build lts binaries for each architecture.
2.4 Build Output
All libraries created can be found under the prebuilt directory.
iOSxcframeworksforMainbuilds are located under thebundle-apple-xcframework-iosfolder.macOSxcframeworksforMainbuilds are located under thebundle-apple-xcframework-macosfolder.tvOSxcframeworksforMainbuilds are located under thebundle-apple-xcframework-tvosfolder.iOSframeworksforMainbuilds are located under thebundle-apple-framework-iosfolder.iOSframeworksforLTSbuilds are located under thebundle-apple-framework-ios-ltsfolder.iOSuniversal (fat) libraries (.a)forLTSbuilds are located under thebundle-apple-universal-ios-ltsfolder.macOSframeworksforMainbuilds are located under thebundle-apple-framework-macosfolder.macOSframeworksforLTSbuilds are located under thebundle-apple-framework-macos-ltsfolder.macOSuniversal (fat) libraries (.a)forLTSbuilds are located under thebundle-apple-universal-macos-ltsfolder.tvOSframeworksforMainbuilds are located under thebundle-apple-framework-tvosfolder.tvOSframeworksforLTSbuilds are located under thebundle-apple-framework-tvos-ltsfolder.tvOSuniversal (fat) libraries (.a)forLTSbuilds are located under thebundle-apple-universal-tvos-ltsfolder.
3. Using
3.1 Objective API
-
Add
FFmpegKitdependency to yourPodfileinffmpeg-kit-<platform>-<package name>pattern. Use one of theFFmpegKitpackage names given in the project README.- iOS
pod 'ffmpeg-kit-ios-full', '~> 4.5'- macOS
pod 'ffmpeg-kit-macos-full', '~> 4.5'- tvOS
pod 'ffmpeg-kit-tvos-full', '~> 4.5' -
Execute synchronous
FFmpegcommands.#include <ffmpegkit/FFmpegKit.h> FFmpegSession *session = [FFmpegKit execute:@"-i file1.mp4 -c:v mpeg4 file2.mp4"]; ReturnCode *returnCode = [session getReturnCode]; if ([ReturnCode isSuccess:returnCode]) { // SUCCESS } else if ([ReturnCode isCancel:returnCode]) { // CANCEL } else { // FAILURE NSLog(@"Command failed with state %@ and rc %@.%@", [FFmpegKitConfig sessionStateToString:[session getState]], returnCode, [session getFailStackTrace]); } -
Each
executecall (sync or async) creates a new session. Access every detail about your execution from the session created.FFmpegSession *session = [FFmpegKit execute:@"-i file1.mp4 -c:v mpeg4 file2.mp4"]; // Unique session id created for this execution long sessionId = [session getSessionId]; // Command arguments as a single string NSString *command = [session getCommand]; // Command arguments NSArray *arguments = [session getArguments]; // State of the execution. Shows whether it is still running or completed SessionState state = [session getState]; // Return code for completed sessions. Will be null if session is still running or ends with a failure ReturnCode *returnCode = [session getReturnCode]; NSDate *startTime =[session getStartTime]; NSDate *endTime =[session getEndTime]; long duration =[session getDuration]; // Console output generated for this execution NSString *output = [session getOutput]; // The stack trace if FFmpegKit fails to run a command NSString *failStackTrace = [session getFailStackTrace]; // The list of logs generated for this execution NSArray *logs = [session getLogs]; // The list of statistics generated for this execution NSArray *statistics = [session getStatistics]; -
Execute asynchronous
FFmpegcommands by providing session specificexecute/log/sessioncallbacks.id<Session> session = [FFmpegKit executeAsync:@"-i file1.mp4 -c:v mpeg4 file2.mp4" withExecuteCallback:^(id<Session> session){ SessionState state = [session getState]; ReturnCode *returnCode = [session getReturnCode]; // CALLED WHEN SESSION IS EXECUTED NSLog(@"FFmpeg process exited with state %@ and rc %@.%@", [FFmpegKitConfig sessionStateToString:state], returnCode, [session getFailStackTrace]); } withLogCallback:^(Log *log) { // CALLED WHEN SESSION PRINTS LOGS } withStatisticsCallback:^(Statistics *statistics) { // CALLED WHEN SESSION GENERATES STATISTICS }]; -
Execute
FFprobecommands.- Synchronous
FFprobeSession *session = [FFprobeKit execute:ffprobeCommand]; if ([ReturnCode isSuccess:[session getReturnCode]]) { NSLog(@"Command failed. Please check output for the details."); }- Asynchronous
[FFprobeKit executeAsync:ffmpegCommand withExecuteCallback:^(id<Session> session) { CALLED WHEN SESSION IS EXECUTED }]; -
Get media information for a file.
MediaInformationSession *mediaInformation = [FFprobeKit getMediaInformation:"<file path or uri>"]; MediaInformation *mediaInformation =[mediaInformation getMediaInformation]; -
Stop ongoing
FFmpegoperations.- Stop all executions
[FFmpegKit cancel]; - Stop a specific session
[FFmpegKit cancel:sessionId];
- Stop all executions
-
Get previous
FFmpegandFFprobesessions from session history.NSArray* sessions = [FFmpegKitConfig getSessions]; for (int i = 0; i < [sessions count]; i++) { id<Session> session = [sessions objectAtIndex:i]; NSLog(@"Session %d = id: %ld, startTime: %@, duration: %ld, state:%@, returnCode:%@.\n", i, [session getSessionId], [session getStartTime], [session getDuration], [FFmpegKitConfig sessionStateToString:[session getState]], [session getReturnCode]); } -
Enable global callbacks.
-
Execute Callback, called when an async execution is ended
[FFmpegKitConfig enableExecuteCallback:^(id<Session> session) { ... }]; -
Log Callback, called when a session generates logs
[FFmpegKitConfig enableLogCallback:^(Log *log) { ... }]; -
Statistics Callback, called when a session generates statistics
[FFmpegKitConfig enableStatisticsCallback:^(Statistics *statistics) { ... }];
-
-
Ignore the handling of a signal. Required by
Monoand frameworks that useMono, e.g.UnityandXamarin.[FFmpegKitConfig ignoreSignal:SIGXCPU]; -
Register system fonts and custom font directories.
[FFmpegKitConfig setFontDirectoryList:[NSArray arrayWithObjects:@"/System/Library/Fonts", @"<folder with fonts>", nil] with:nil];
4. Test Application
You can see how FFmpegKit is used inside an application by running iOS, macOS and tvOS test applications
developed under the FFmpegKit Test project.