Convert Figma logo to code with AI

arthenica logoffmpeg-kit

FFmpeg Kit for applications. Supports Android, Flutter, iOS, Linux, macOS, React Native and tvOS. Supersedes MobileFFmpeg, flutter_ffmpeg and react-native-ffmpeg.

4,283
575
4,283
67

Top Related Projects

45,445

Mirror of https://git.ffmpeg.org/ffmpeg.git

FFmpeg for Android, iOS and tvOS. Not maintained anymore. Superseded by FFmpegKit.

The FFmpeg build script provides an easy way to build a static FFmpeg on OSX and Linux with non-free codecs included.

1,403

Docker build for FFmpeg on Ubuntu / Alpine / Centos / Scratch / nvidia / vaapi

Quick Overview

FFmpeg-kit is a powerful and versatile mobile FFmpeg library that supports Android, iOS, and React Native platforms. It provides a comprehensive set of tools for handling audio and video processing tasks, including encoding, decoding, filtering, and format conversion, all optimized for mobile devices.

Pros

  • Cross-platform support for Android, iOS, and React Native
  • Extensive set of audio and video processing capabilities
  • Optimized for mobile devices, ensuring efficient performance
  • Regular updates and active community support

Cons

  • Steep learning curve for beginners due to the complexity of FFmpeg
  • Large library size may increase app bundle size
  • Some advanced features may require additional configuration or plugins

Code Examples

  1. Basic video conversion:
FFmpegKit.execute("-i input.mp4 -c:v mpeg4 output.mp4")
  1. Extracting audio from a video:
FFmpegKit.execute("-i input.mp4 -vn -acodec copy output.aac")
  1. Applying a video filter:
FFmpegKit.execute("-i input.mp4 -vf "scale=640:480" output.mp4")
  1. Handling execution callback:
FFmpegKit.executeAsync("-i input.mp4 -c:v libx264 output.mp4") { session ->
    if (ReturnCode.isSuccess(session.returnCode)) {
        println("Success")
    } else {
        println("Error: ${session.failStackTrace}")
    }
}

Getting Started

  1. Add the FFmpeg-kit dependency to your project:

For Android (in build.gradle):

dependencies {
    implementation 'com.arthenica:ffmpeg-kit-full:5.1'
}

For iOS (in Podfile):

pod 'ffmpeg-kit-ios-full', '5.1'
  1. Import the library in your code:

For Android (Kotlin):

import com.arthenica.ffmpegkit.FFmpegKit

For iOS (Swift):

import ffmpegkit
  1. Execute an FFmpeg command:
FFmpegKit.execute("-i input.mp4 -c:v libx264 -crf 23 -preset medium -c:a aac -b:a 128k output.mp4")

Remember to handle permissions and file access according to your platform's requirements.

Competitor Comparisons

45,445

Mirror of https://git.ffmpeg.org/ffmpeg.git

Pros of FFmpeg

  • Comprehensive and widely-used multimedia framework with extensive codec support
  • Active development with frequent updates and improvements
  • Highly customizable and suitable for a wide range of use cases

Cons of FFmpeg

  • Steep learning curve for beginners
  • Complex command-line interface can be challenging for non-technical users
  • Requires manual compilation and setup for mobile platforms

Code Comparison

FFmpeg:

ffmpeg -i input.mp4 -vf scale=1280:720 output.mp4

ffmpeg-kit:

FFmpegKit.execute("-i input.mp4 -vf scale=1280:720 output.mp4");

Key Differences

  • ffmpeg-kit is specifically designed for mobile platforms (iOS, Android, React Native)
  • ffmpeg-kit provides a simplified API for integrating FFmpeg into mobile applications
  • FFmpeg is a standalone tool, while ffmpeg-kit is a wrapper library for mobile development

Use Cases

  • FFmpeg: Server-side video processing, desktop applications, command-line tools
  • ffmpeg-kit: Mobile apps requiring video processing capabilities, cross-platform mobile development

Community and Support

  • FFmpeg has a larger community and extensive documentation
  • ffmpeg-kit has focused support for mobile developers and platform-specific issues

FFmpeg for Android, iOS and tvOS. Not maintained anymore. Superseded by FFmpegKit.

Pros of mobile-ffmpeg

  • Longer development history and more established community
  • Wider range of supported platforms, including iOS, Android, and Linux
  • More comprehensive documentation and examples

Cons of mobile-ffmpeg

  • Less frequent updates and maintenance
  • Larger binary size due to inclusion of more libraries and codecs
  • Slightly more complex integration process for some platforms

Code Comparison

mobile-ffmpeg:

FFmpeg.execute("-i input.mp4 -c:v mpeg4 output.mp4");

ffmpeg-kit:

FFmpegKit.execute("-i input.mp4 -c:v mpeg4 output.mp4");

Key Differences

  1. ffmpeg-kit is a more recent project, forked from mobile-ffmpeg
  2. ffmpeg-kit offers improved performance and smaller binary sizes
  3. ffmpeg-kit provides better support for newer FFmpeg versions
  4. mobile-ffmpeg has a larger user base and more third-party resources

Conclusion

While mobile-ffmpeg has been around longer and supports more platforms, ffmpeg-kit offers improved performance and more frequent updates. The choice between the two depends on specific project requirements, such as platform support, binary size constraints, and the need for the latest FFmpeg features.

Pros of FFmpeg-Builds

  • Provides pre-built FFmpeg binaries for multiple platforms
  • Offers various build configurations, including shared and static libraries
  • Regularly updated with the latest FFmpeg versions

Cons of FFmpeg-Builds

  • Limited to pre-built binaries, not designed for easy integration into mobile apps
  • Lacks specific mobile platform optimizations
  • Does not provide high-level APIs for easier FFmpeg usage in applications

Code Comparison

FFmpeg-Kit:

FFmpegKit.executeAsync("-i input.mp4 -c:v mpeg4 output.mp4", new FFmpegSessionCompleteCallback() {
    @Override
    public void apply(FFmpegSession session) {
        // Handle completion
    }
});

FFmpeg-Builds:

// No direct API provided, requires manual FFmpeg library integration
AVFormatContext *inputContext = avformat_alloc_context();
avformat_open_input(&inputContext, "input.mp4", NULL, NULL);
// Additional code required for processing and output

FFmpeg-Kit provides a higher-level API for easier integration, especially in mobile applications, while FFmpeg-Builds offers more flexibility for custom builds and configurations across various platforms. FFmpeg-Kit is more suitable for mobile development, whereas FFmpeg-Builds is better for desktop applications or scenarios requiring specific FFmpeg builds.

The FFmpeg build script provides an easy way to build a static FFmpeg on OSX and Linux with non-free codecs included.

Pros of ffmpeg-build-script

  • Simpler and more lightweight, focusing solely on building FFmpeg from source
  • Offers more customization options for the FFmpeg build process
  • Supports a wider range of operating systems, including Linux, macOS, and Windows

Cons of ffmpeg-build-script

  • Lacks mobile platform support (iOS, Android)
  • Does not provide a high-level API for integrating FFmpeg into applications
  • Requires more manual configuration and setup compared to ffmpeg-kit

Code Comparison

ffmpeg-build-script:

./build-ffmpeg --build

ffmpeg-kit:

FFmpegKit.execute("-i input.mp4 -c:v mpeg4 output.mp4");

The code comparison highlights the difference in focus between the two projects. ffmpeg-build-script is primarily used for building FFmpeg from source, while ffmpeg-kit provides a high-level API for integrating FFmpeg functionality into applications, particularly on mobile platforms.

ffmpeg-build-script is better suited for users who need a customized FFmpeg build or want more control over the compilation process. On the other hand, ffmpeg-kit is ideal for developers looking to integrate FFmpeg capabilities into their applications, especially on mobile platforms, with a more user-friendly API.

1,403

Docker build for FFmpeg on Ubuntu / Alpine / Centos / Scratch / nvidia / vaapi

Pros of ffmpeg

  • Simpler setup and usage for basic FFmpeg operations
  • Lightweight Docker images optimized for various environments
  • Extensive documentation and examples for Docker deployment

Cons of ffmpeg

  • Limited to Docker environments, less flexible for native integration
  • Fewer platform-specific optimizations compared to FFmpeg-kit
  • May require additional configuration for complex use cases

Code Comparison

FFmpeg (Dockerfile excerpt):

FROM alpine:3.18
RUN apk add --no-cache ffmpeg
ENTRYPOINT ["ffmpeg"]

FFmpeg-kit (Android integration):

FFmpegKit.executeAsync("-i input.mp4 -c:v mpeg4 output.mp4", 
    new FFmpegSessionCompleteCallback() {
        @Override
        public void apply(FFmpegSession session) {
            // Handle completion
        }
    });

FFmpeg-kit offers more granular control and platform-specific optimizations, while ffmpeg provides a straightforward Docker-based approach for FFmpeg usage. FFmpeg-kit is better suited for native mobile and web applications, whereas ffmpeg is ideal for containerized environments and server-side processing.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

FFmpegKit GitHub release Maven Central CocoaPods pub npm

FFmpegKit is a collection of tools to use FFmpeg in Android, iOS, Linux, macOS, tvOS, Flutter and React Native applications.

It includes scripts to build FFmpeg native libraries, a wrapper library to run FFmpeg/FFprobe commands in applications and 8 prebuilt binary packages available at Github, Maven Central, CocoaPods, pub and npm.

1. Features

  • Scripts to build FFmpeg native libraries
  • FFmpegKit wrapper library to run FFmpeg/FFprobe commands in applications
  • Supports native platforms: Android, iOS, Linux, macOS and tvOS
  • Supports hybrid platforms: Flutter, React Native
  • Based on FFmpeg v4.5-dev or later with optional system and external libraries
  • 8 prebuilt binary packages available at Github, Maven Central, CocoaPods, pub and npm
  • Licensed under LGPL 3.0 by default, GPL v3.0 if GPL licensed libraries are enabled

2. Android

See Android to learn more about FFmpegKit for Android.

3. iOS, macOS, tvOS

See Apple to use FFmpegKit on Apple platforms (iOS, macOS, tvOS).

4. Flutter

See Flutter to learn more about FFmpegKit for Flutter.

5. Linux

See Linux to learn more about FFmpegKit for Linux.

6. React Native

See React Native to learn more about FFmpegKit for React Native.

7. Build Scripts

Use android.sh, ios.sh, linux.sh, macos.sh and tvos.sh to build FFmpegKit for each native platform.

All scripts support additional options to enable optional libraries and disable platform architectures. See Building wiki page for the details.

8. FFmpegKit Library

FFmpegKit is a wrapper library that allows you to easily run FFmpeg/FFprobe commands in applications. It provides additional features on top of FFmpeg to enable platform specific resources, control how commands are executed and how the results are handled.

Android library of FFmpegKit has a Java API, Apple libraries (iOS, macOS, tvOS) have an Objective-C API, Flutter library comes with a Dart API, Linux library has a C++ API and React Native library provides a JavaScript API with Typescript definitions, which are identical in terms of features and capabilities.

9. Packages

There are eight different ffmpeg-kit packages distributed on Github, Maven Central, CocoaPods, pub and npm. Below you can see which system libraries and external libraries are enabled in each one of them.

Please remember that some parts of FFmpeg are licensed under the GPL and only GPL licensed ffmpeg-kit packages include them.

min min-gpl https https-gpl audio video full full-gpl
external libraries - vid.stab
x264
x265
xvidcore
gmp
gnutls
gmp
gnutls
vid.stab
x264
x265
xvidcore
lame
libilbc
libvorbis
opencore-amr
opus
shine
soxr
speex
twolame
vo-amrwbenc
dav1d
fontconfig
freetype
fribidi
kvazaar
libass
libiconv
libtheora
libvpx
libwebp
snappy
zimg
dav1d
fontconfig
freetype
fribidi
gmp
gnutls
kvazaar
lame
libass
libiconv
libilbc
libtheora
libvorbis
libvpx
libwebp
libxml2
opencore-amr
opus
shine
snappy
soxr
speex
twolame
vo-amrwbenc
zimg
dav1d
fontconfig
freetype
fribidi
gmp
gnutls
kvazaar
lame
libass
libiconv
libilbc
libtheora
libvorbis
libvpx
libwebp
libxml2
opencore-amr
opus
shine
snappy
soxr
speex
twolame
vid.stab
vo-amrwbenc
x264
x265
xvidcore
zimg
android system libraries zlib
MediaCodec
ios system libraries bzip2
AudioToolbox
AVFoundation
iconv
VideoToolbox
zlib
macos system libraries bzip2
AudioToolbox
AVFoundation
Core Image
iconv
OpenCL
OpenGL
VideoToolbox
zlib
tvos system libraries bzip2
AudioToolbox
iconv
VideoToolbox
zlib
  • AVFoundation is not available on tvOS
  • VideoToolbox is not available on LTS releases of iOS and tvOS
  • zimg is supported since v4.5.1

10. Versions

FFmpegKit binaries generated use the same major and minor version numbers as the upstream FFmpeg project. The third and last number in the version string, if exists, is specific to FFmpegKit. It shows different releases from the same FFmpeg release branch.

dev part in the version string indicates that FFmpeg source code is cloned from the FFmpeg master branch and the exact version number of FFmpeg is obtained using the git describe --tags command.

PlatformsFFmpegKit VersionFFmpeg VersionRelease Date
Flutter6.0.36.0Sep 19, 2023
React Native6.0.26.0Sep 19, 2023
Flutter6.0.26.0Sep 03, 2023
React Native6.0.16.0Sep 03, 2023
Flutter6.0.16.0Sep 03, 2023
React Native6.0.06.0Aug 27, 2023
Flutter6.0.06.0Aug 27, 2023
Android
Apple
6.06.0Aug 21, 2023
React Native5.1.05.1.2Oct 02, 2022
Flutter5.1.05.1.2Oct 02, 2022
Android
Apple
5.15.1.2Sep 29, 2022
React Native4.5.24.5-dev-3393May 25, 2022
Flutter4.5.14.5-dev-3393Jan 02, 2022
React Native4.5.14.5-dev-3393Jan 02, 2022
Android4.5.14.5-dev-3393Jan 01, 2022
Apple4.5.14.5-dev-3393Dec 30, 2021
Flutter4.5.04.5-dev-2008Oct 05, 2021
React Native4.5.04.5-dev-2008Oct 01, 2021
Android
Apple
4.54.5-dev-2008Sep 18, 2021
Android
Apple
4.44.4-dev-3015Mar 03, 2021

11. LTS Releases

FFmpegKit binaries are published in two release variants: Main Release and LTS Release.

  • Main releases include complete functionality of the library and support the latest SDK/API features.

  • LTS releases are customized to support a wider range of devices. They are built using older API/SDK versions, so some features are not available on them.

This table shows the differences between two variants.

Main ReleaseLTS Release
Android API Level2416
Android Camera AccessYes-
Android Architecturesarm-v7a-neon
arm64-v8a
x86
x86-64
arm-v7a
arm-v7a-neon
arm64-v8a
x86
x86-64
iOS Min SDK12.110
iOS VideoToolboxYes-
iOS AVFoundationYes-
iOS Architecturesarm64
arm64-simulator
arm64-mac-catalyst
x86-64
x86-64-mac-catalyst
armv7
arm64
i386
x86-64
iOS Bundle FormatXCFrameworksFrameworks
Mac Catalyst Min Version14.0-
macOS Min SDK10.1510.12
macOS AVFoundationYes-
macOS Architecturesarm64
x86-64
x86-64
macOS Bundle FormatXCFrameworksFrameworks
tvOS Min SDK11.010.0
tvOS VideoToolboxYes-
tvOS Architecturesarm64
x86-64
arm64-simulator
arm64
x86-64
tvOS Bundle FormatXCFrameworksFrameworks

12. Documentation

A more detailed documentation is available under Wiki.

13. Test Applications

You can see how FFmpegKit is used inside an application by running test applications created under FFmpegKit Test project.

All applications are identical and supports command execution, video encoding, accessing https urls, encoding audio, burning subtitles, video stabilisation, pipe operations and concurrent command execution.

14. License

FFmpegKit library alone is licensed under the LGPL v3.0.

FFmpegKit bundles (.aar archives, frameworks, xcframeworks), which include both FFmpegKit and FFmpeg libraries, are also licensed under the LGPL v3.0. However, if the source code is built using the optional --enable-gpl flag or prebuilt binaries with -gpl postfix are used, then FFmpegKit bundles become subject to the GPL v3.0. Because, FFmpeg is licensed under the GPL v3.0 in those bundles. And that makes the whole bundle effectively subject to the GPL v3.0.

FFmpegKit build scripts always configure FFmpeg with --enable-version3 option. And never enable non-free libraries. Thus, FFmpeg libraries created by FFmpegKit are licensed under the LGPL v3.0 by default. Only when --enable-gpl is provided they become subject to GPL v3.0. That is how prebuilt binaries with -gpl postfix are compiled.

Refer to Licenses to see the licenses of all libraries. Trademark lists the trademarks used in the FFmpegKit documentation.

15. Patents

It is not clearly explained in their documentation, but it is believed that FFmpeg, kvazaar, x264 and x265 include algorithms which are subject to software patents. If you live in a country where software algorithms are patentable then you'll probably need to pay royalty fees to patent holders. We are not lawyers though, so we recommend that you seek legal advice first. See FFmpeg Patent Mini-FAQ.

openh264 clearly states that it uses patented algorithms. Therefore, if you build ffmpeg-kit with openh264 and distribute that library, then you are subject to pay MPEG LA licensing fees. Refer to OpenH264 FAQ page for the details.

16. Contributing

See our CONTRIBUTING guide.

17. See Also

NPM DownloadsLast 30 Days