Skip to content
Taner Şener edited this page Jun 7, 2022 · 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.

Clone this wiki locally