Skip to content
Taner Sener edited this page Apr 11, 2024 · 12 revisions

1. Using Space Character In a Command String

execute() and executeAsync() methods in FFmpegKit and FFprobeKit splits a command into arguments by using the space character as a delimiter. If one of your command parameters include a space character inside then it will be split into two parameters and your command execution will fail. To prevent that, wrap that parameter using single or double quotes. Wrapping will prevent the parameter from being split.

Alternatively, you can split your command into arguments yourself and call one of the overloaded executeWithArguments()/executeWithArgumentsAsync() methods that accept arguments array.


2. Depending Another Android Library Containing libc++_shared.so

FFmpegKit packages specified in Android C++ Dependency Guide include libc++_shared.so library. If a second library which also includes libc++_shared.so is added as a dependency, gradle fails with More than one file was found with OS independent path 'lib/x86/libc++_shared.so' error message.

You can fix this error by adding the following block into your build.gradle.

android {
    packagingOptions {
        pickFirst 'lib/x86/libc++_shared.so'
        pickFirst 'lib/x86_64/libc++_shared.so'
        pickFirst 'lib/armeabi-v7a/libc++_shared.so'
        pickFirst 'lib/arm64-v8a/libc++_shared.so'
    }
}

3. Burning Subtitles on Android

ffmpeg requires a valid fontconfig configuration to render subtitles. Unfortunately, Android does not include a default fontconfig configuration. Therefore, if you do not register a font or specify a fontconfig configuration under Android, then the burning process will not produce any errors but subtitles won't be burned into your file.

You can overcome this behaviour by registering the fonts under a directory using the FFmpegKitConfig.setFontDirectory methods or by specifying your own fontconfig configuration using FFmpegKitConfig.setFontconfigConfigurationPath.


4. drawtext Filter on Android

ffmpeg requires a valid fontconfig configuration to render text while using drawtext filter. As described in #3, Android does not include a default fontconfig configuration. So, if you do not register a font or specify a fontconfig configuration under Android, then drawtext filter will fail with the following error.

Cannot find a valid font for the family Sans
Error initializing filter 'drawtext'
Error reinitializing filters!
Failed to inject frame into filter network: No such file or directory

You can overcome this behaviour by registering the fonts under a directory using the FFmpegKitConfig.setFontDirectory methods or by specifying your own fontconfig configuration using FFmpegKitConfig.setFontconfigConfigurationPath.


5. Using System Fonts on Android

System fonts on Android are stored under the /system/fonts folder. You can use those fonts in your ffmpeg commands by registering /system/fonts as a font directory via the FFmpegKitConfig.setFontDirectory methods.


6. Using System Fonts on Apple Platforms

System fonts on Apple platforms (iOS, macOS, tvOS) are stored under the /System/Library/Fonts and/or /System/Library/Fonts/Cache folders. You can use those fonts in your ffmpeg commands by registering /System/Library/Fonts as a font directory via the [FFmpegKitConfig setFontDirectory] methods.


7. Installing the LTS Versions on Flutter

If you use the caret syntax to define the LTS version in pubspec.yaml e.g. ffmpeg_kit_flutter: ^4.5.0-LTS, flutter pub get may install the non-LTS version of the plugin. You can resolve this by not using the caret syntax and defining the exact LTS version in pubspec.yaml.


8. UDP Streaming Support on Android

Android doesn't support UDP streaming since its pthreads implementation lacks a few components required by ffmpeg's udp module. When you try to initiate a new UDP connection ffmpeg will not transmit any UDP packets. It will only print the following message to the console and stop there.

[udp @ 0x5d0b3962] 'circular_buffer_size' option was set but it is not supported on this build (pthread support is required)

Unfortunately, there is no workaround for that. The only alternative is to use tcp by providing an extra flag e.g. -rtsp_transport tcp.


9. drawtext Not Found

drawtext filter depends on freetype by default. It also requires fontconfig to use fonts. If you're using an ffmpeg-kit package that doesn't include those libraries then your commands will fail with the following error.

No such filter: 'drawtext'


10. Minimum Deployment Target in Podfile

On Apple platforms, when an application uses a lower deployment target than the one needed by ffmpeg-kit, the build may fail printing the following error.

Specs satisfying the ffmpeg_kit_... dependency were found, but they required a higher minimum deployment target.

To fix this error, first find the minimum sdk target required for your ffmpeg-kit release from Xcode Compatibility page. Then update your Podfile file with the value listed there. That should resolve the issue.

platform :ios, '12.1'


11. Using PNG files on Apple Platforms

By default, Xcode optimises all PNG files in an application bundle. However, this optimisation may result in PNG files that cannot be decoded by the libpng library, which FFmpeg depends on. If this occurs, your command will fail and print the following error message to the console.

Error while decoding stream #0:0: Generic error in an external library

To fix this error, go to Build Settings in Xcode and disable Compress PNG Files and Remove Text Metadata From PNG Files options under the Packaging. Note that these options are hidden and only become visible when a file with .png extension is added to the project.


Clone this wiki locally