|
|
5 years ago | |
|---|---|---|
| .. | ||
| m4 | 5 years ago | |
| src | 5 years ago | |
| .gitignore | 5 years ago | |
| Doxyfile | 5 years ago | |
| Makefile.am | 5 years ago | |
| Makefile.in | 5 years ago | |
| README.md | 5 years ago | |
| aclocal.m4 | 5 years ago | |
| ar-lib | 5 years ago | |
| autogen.sh | 5 years ago | |
| compile | 5 years ago | |
| config.guess | 5 years ago | |
| config.sub | 5 years ago | |
| configure | 5 years ago | |
| configure.ac | 5 years ago | |
| depcomp | 5 years ago | |
| install-sh | 5 years ago | |
| libtool | 5 years ago | |
| ltmain.sh | 5 years ago | |
| missing | 5 years ago | |
README.md
FFmpegKit for iOS, macOS and tvOS
1. Features
1.1 iOS
- Builds
armv7,armv7s,arm64,arm64-simulator,arm64e,i386,x86_64,x86_64-mac-catalystandarm64-mac-catalystarchitectures - Supports
bzip2,iconv,libuuid,zlibsystem libraries andAudioToolbox,AVFoundation,VideoToolboxsystem frameworks - Objective-C API
- Camera access
ARCenabled library- Built with
-fembed-bitcodeflag - Creates static
frameworks, staticxcframeworksand staticuniversal (fat)libraries (.a) - Supports
iOS SDK 9.3or later
1.2 macOS
- Builds
arm64andx86_64architectures - Supports
bzip2,iconv,libuuid,zlibsystem libraries andAudioToolbox,AVFoundation,CoreImage,OpenCL,OpenGL,VideoToolboxsystem frameworks - Objective-C API
- Camera access
ARCenabled library- Built with
-fembed-bitcodeflag - Creates static
frameworks, staticxcframeworksand staticuniversal (fat)libraries (.a) - Supports
macOS SDK 10.11or later
1.3 tvOS
- Builds
arm64,arm64-simulatorandx86_64architectures - Supports
bzip2,iconv,libuuid,zlibsystem libraries andAudioToolbox,VideoToolboxsystem frameworks - Objective-C API
ARCenabled library- Built with
-fembed-bitcodeflag - Creates static
frameworks, staticxcframeworksand staticuniversal (fat)libraries (.a) - Supports
tvOS SDK 9.2or later
2. Building
Run ios.sh/macos.sh/tvos.sh at project root directory to build ffmpeg-kit and ffmpeg shared libraries for a
platform.
Optionally, use apple.sh to combine bundles created by these three scripts in a single bundle.
2.1 Prerequisites
ios.sh/macos.sh/tvos.sh requires the following packages and tools.
-
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 -
ios.sh/macos.sh/tvos.shneeds network connectivity and internet access togithub.comin order to download the source code of all libraries exceptffmpeg-kit. -
Install the tools necessary listed below in
2.1.x.
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.2 Options
Use --enable-<library name> flags 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.4.LTS'- macOS
pod 'ffmpeg-kit-macos-full', '~> 4.4.LTS'- tvOS
pod 'ffmpeg-kit-tvos-full', '~> 4.4.LTS' -
Execute synchronous FFmpeg commands.
#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]); } -
Execute asynchronous FFmpeg commands by providing session specific execute/log/session callbacks.
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 synchronous FFprobe commands.
FFprobeSession *session = [FFprobeKit execute:ffprobeCommand]; if ([ReturnCode isSuccess:[session getReturnCode]]) { NSLog(@"Command failed. Please check output for the details."); } -
Get session output.
FFmpegSession session = FFmpegKit.execute("-i file1.mp4 -c:v mpeg4 file2.mp4"); NSLog([session getOutput]); -
Stop ongoing FFmpeg operations.
- Stop all executions
[FFmpegKit cancel]; - Stop a specific session
[FFmpegKit cancel:sessionId];
- Stop all executions
-
Get media information for a file.
MediaInformationSession *mediaInformation = [FFprobeKit getMediaInformation:"<file path or uri>"]; MediaInformation *mediaInformation =[mediaInformation getMediaInformation]; -
List previous FFmpeg sessions.
NSArray* ffmpegSessions = [FFmpegKit listSessions]; for (int i = 0; i < [ffmpegSessions count]; i++) { FFmpegSession* session = [ffmpegSessions 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]); }
4. Test Application
You can see how FFmpegKit is used inside an application by running test applications developed under the
FFmpegKit Test project.