iOS SDK 12.1+
on Main releases and iOS SDK 9.3+
on LTS releasesarmv7
, armv7s
, arm64
, arm64-simulator
, arm64e
, i386
, x86_64
, x86_64-mac-catalyst
and
arm64-mac-catalyst
architecturesARC
enabled library-fembed-bitcode
flagframeworks
, static xcframeworks
and static universal (fat)
libraries (.a)macOS SDK 10.15+
on Main releases and macOS SDK 10.11+
on LTS releasesarm64
and x86_64
architecturesARC
enabled library-fembed-bitcode
flagframeworks
, static xcframeworks
and static universal (fat)
libraries (.a)tvOS SDK 10.2+
on Main releases and tvOS SDK 9.2+
on LTS releasesarm64
, arm64-simulator
and x86_64
architecturesARC
enabled library-fembed-bitcode
flagframeworks
, static xcframeworks
and static universal (fat)
libraries (.a)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.
ios.sh
, macos.sh
and tvos.sh
require the following tools and 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
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.
Use --lts
option to build lts binaries for each architecture.
All libraries created can be found under the prebuilt
directory.
iOS
xcframeworks
for Main
builds are located under the bundle-apple-xcframework-ios
folder.macOS
xcframeworks
for Main
builds are located under the bundle-apple-xcframework-macos
folder.tvOS
xcframeworks
for Main
builds are located under the bundle-apple-xcframework-tvos
folder.iOS
frameworks
for Main
builds are located under the bundle-apple-framework-ios
folder.iOS
frameworks
for LTS
builds are located under the bundle-apple-framework-ios-lts
folder.iOS
universal (fat) libraries (.a)
for LTS
builds are located under the bundle-apple-universal-ios-lts
folder.macOS
frameworks
for Main
builds are located under the bundle-apple-framework-macos
folder.macOS
frameworks
for LTS
builds are located under the bundle-apple-framework-macos-lts
folder.macOS
universal (fat) libraries (.a)
for LTS
builds are located under the bundle-apple-universal-macos-lts
folder.tvOS
frameworks
for Main
builds are located under the bundle-apple-framework-tvos
folder.tvOS
frameworks
for LTS
builds are located under the bundle-apple-framework-tvos-lts
folder.tvOS
universal (fat) libraries (.a)
for LTS
builds are located under the bundle-apple-universal-tvos-lts
folder.Add FFmpegKit
dependency to your Podfile
in ffmpeg-kit-<platform>-<package name>
pattern. Use one of the
FFmpegKit
package names given in the project README.
pod 'ffmpeg-kit-ios-full', '~> 4.4.LTS'
pod 'ffmpeg-kit-macos-full', '~> 4.4.LTS'
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]);
}
Each execute
call (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 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 FFprobe
commands.
FFprobeSession *session = [FFprobeKit execute:ffprobeCommand];
if ([ReturnCode isSuccess:[session getReturnCode]]) {
NSLog(@"Command failed. Please check output for the details.");
}
[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 FFmpeg
operations.
[FFmpegKit cancel];
[FFmpegKit cancel:sessionId];
Get previous FFmpeg
and FFprobe
sessions 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 Mono
and frameworks that use Mono
, e.g. Unity
and Xamarin
.
[FFmpegKitConfig ignoreSignal:SIGXCPU];
Register system fonts and custom font directories.
[FFmpegKitConfig setFontDirectoryList:<array of folders with fonts> with:nil];
You can see how FFmpegKit
is used inside an application by running iOS
, macOS
and tvOS
test applications
developed under the FFmpegKit Test project.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。