Registered pipes can't be used on Windows

Open
#175 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
58/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
c, dart, flutter

Research direction

Start by inspecting windows/src/FFmpegKitConfig.cpp around the linked lines 844–845 and trace how the registered pipe is created, returned, and closed. Compare that lifecycle with the working Android behavior described in the issue; reproduce by registering a pipe, opening it with Dart File(pipePath).openWrite(), and running the shown FFmpeg command. Done means Windows can open and feed the registered pipe and FFmpeg receives the streamed input.

Written by the indexing model from the issue text.

Description

Hi, I'm running into an issue with the custom Windows implementation when trying to register a pipe for an input file.

Here is the rough setup:

final pipePath = await FFmpegKitConfig.registerNewFFmpegPipe();
if (pipePath == null) {
  throw StateError('Failed to register new FFmpeg pipe');
}

await FFmpegKit.executeWithArgumentsAsync(
  [
    ...['-i', pipePath],
    ...['-af', 'ebur128'], // Measures loudness, produces logs every 100ms
    ...['-f', 'null'],
    '-',
  ],
  (session) {},
  (log) => print('[ffmpeg] ${log.getMessage()}'),
);

final ffmpegInputSink = File(pipePath).openWrite();

// Here you listen to a Stream<Uint8List> and pipe it to ffmpegInputSink,
// for example by using AudioRecorder().startStream() from the Flutter "record" package.

// ... when done:
await ffmpegInputSink.flush();
await ffmpegInputSink.close();
await FFmpegKitConfig.closeFFmpegPipe(pipePath);

On Android, this creates a pipe, which can be fed with a stream of data and then properly closed. The ffmpeg logs respond to the audio loudness as expected (everything works here).

On Windows, you also get back a valid pipePath (e.g. \\.\pipe\fk_pipe_1). However, this pipe doesn't actually exist. The File(pipePath).openWrite() command fails ("Cannot open file"), and the ffmpeg logs say:

[ffmpeg] \\.\pipe\fk_pipe_1: No such file or directory

I assume this has something to do with a line in FFmpegKitConfig.cpp, where the pipe gets closed before returning it to the Dart side:

https://github.com/sk3llo/ffmpeg_kit_flutter/blob/f1f7fe2d40f166ccfa76ca78d19ffa280f51e825/windows/src/FFmpegKitConfig.cpp#L844-L845

Apologies if the ffmpeg-kit repository would have been a better place for this issue. I wasn't sure, because the Windows source files are also part of this repository.

Anyway, thanks for maintaining this plugin!

Dominant language
C
Stars
182
Forks
122
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from sk3llo/ffmpeg_kit_flutter

All issues in sk3llo/ffmpeg_kit_flutter

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.