I’m trying to pipe data into my app. I’m using Process
to run a command which outputs to stdout
.
If I try to read that output, using the methods available to Sys.stdin()
, the app becomes unresponsive, seemingly waiting for keyboard input in the terminal. It does not seem to be receiving the piped stdout data from ffmpeg.
I’ve produced a simplified example that reproduces the issues. In this example, ffmpeg is reading from a video file, transcoding it to mjpeg (-c:v mjpeg -f mjpeg
) and outputting it to stdout (pipe:1
).
package;
import openfl.utils.Assets;
import openfl.display.Sprite;
import openfl.events.Event;
import sys.io.Process;
class Main extends Sprite {
public function new() {
super();
trace(Assets.exists('assets/bbb_sunflower_1080p_30fps_normal.mp4')); // true
var process:Process = new Process('ffmpeg -i assets/bbb_sunflower_1080p_30fps_normal.mp4 -an -c:v mjpeg -f mjpeg pipe:1');
addEventListener(Event.ENTER_FRAME, enterFrameHandler);
}
private function enterFrameHandler(e:Event):Void {
try {
trace(Sys.stdin().readByte());
} catch (e:haxe.io.Eof) {
trace("done!");
}
}
}
Command:
openfl test neko -debug
openfl test cpp -debug
- Targeting: cpp (final) and neko (testing)
- System: Linux 64bit (Arch based)
- Haxe: [4.2.4]
- hxcpp: [4.2.1]
- OpenFL: [git]