Skip to content

Pipe Support

Taner Sener edited this page Jul 15, 2026 · 1 revision

FFmpegKitNext executes ffmpeg and ffprobe commands directly. It does not run commands through a shell, so shell features such as starting another process and piping its output into ffmpeg or ffprobe are not supported inside execute() calls.

For example, the following command will fail if passed to an execute() method:

cat <image path> | -i pipe: video.mp4

It fails because FFmpegKitNext sends the command to ffmpeg, not to a shell.

Unable to find a suitable output format for 'cat'

However, the pipe: protocol is still supported. You can use data produced by another process in your ffmpeg or ffprobe command by creating a named pipe, feeding that pipe, and using the pipe path as an input or output in your command.

FFmpegKitNext provides the registerNewFFmpegPipe method on the FFmpegKitConfig class to create named pipes. You are responsible for closing each pipe with closeFFmpegPipe when it is no longer needed.

Android

1. Create a new pipe

String pipe1 = FFmpegKitConfig.registerNewFFmpegPipe(mainActivity);

2. Build your command using the pipe

String ffmpegCommand = "-i " + pipe1 + " -r 25 <output video path>";

3. Execute your command asynchronously

FFmpegKit.executeAsync(ffmpegCommand);

4. Push data to the pipe from another process

Runtime.getRuntime().exec(new String[]{"sh", "-c", "cat <image path> > " + pipe1});

5. Close the pipe

FFmpegKitConfig.closeFFmpegPipe(pipe1);

ffmpeg waits until data is available in the pipe. If no process writes to the pipe, the command will wait indefinitely.

iOS / iPadOS / macOS / tvOS / visionOS

The same approach can be used on Apple platforms. The Objective-C API provides registerNewFFmpegPipe and closeFFmpegPipe methods on the FFmpegKitConfig class, so creating the pipe and using it in an ffmpeg command works the same way.

On iOS, iPadOS, tvOS and visionOS applications cannot start arbitrary external processes. For a portable Apple implementation, write data to the pipe manually by opening the pipe with NSFileHandle and calling writeData.

Linux

The Linux C++ API also provides registerNewFFmpegPipe and closeFFmpegPipe methods on the FFmpegKitConfig class.

#include <cstdlib>
#include <string>
#include <thread>

#include <FFmpegKit.h>
#include <FFmpegKitConfig.h>

using namespace ffmpegkit;

auto pipe1 = FFmpegKitConfig::registerNewFFmpegPipe();

if (pipe1 != nullptr) {
    std::string ffmpegCommand = "-i " + *pipe1 + " -r 25 <output video path>";

    std::thread writer([pipe1]() {
        std::string command = "cat <image path> > " + *pipe1;
        std::system(command.c_str());
    });

    FFmpegKit::execute(ffmpegCommand);

    writer.join();

    FFmpegKitConfig::closeFFmpegPipe(*pipe1);
}

The writer must run in another thread or process. If FFmpegKit::execute starts first and nothing writes to the pipe, the command will block while waiting for input.

Flutter / React Native

In addition to the standard pipe methods available in all APIs, FFmpegKitNext plugins for Flutter and React Native provide a writeToPipe method on the FFmpegKitConfig class. You can use writeToPipe instead of starting another process to feed data into the pipe.

Note: All test applications in the FFmpegKitNext Test repository include a PIPE tab that demonstrates a similar scenario.

Clone this wiki locally