-
-
Notifications
You must be signed in to change notification settings - Fork 132
Getting standard output #71
Comments
Is this an |
Hello, |
|
Yes, I would like to get the output of flutter_ffmpeg as an in-memory buffer (list of 8-bit unsigned integers) representing the data from the file, without having to write the output to a temporary file then read it again. Is there a way to achieve this with flutter_ffmpeg? |
No. I can try to implement this feature but the second part of this functionality would be a method/plugin which allows you to read memory and use it. Do you know a method/plugin which does that in |
I assumed flutter_ffmpeg would return (or provide a getter for) the buffer as a Dart list of 8-bit unsigned integers, which I could then process further from Dart code. Is that doable? |
Technically, |
Yes I agree, I already do |
Nevermind, I digged a bit deeper and I saw that flutter_ffmpeg uses the mobile-ffmpeg library which calls into native code in https://github.com/tanersener/mobile-ffmpeg/blob/master/android/app/src/main/cpp/mobileffmpeg.c so my comment about Java method getInputStream does not apply. You said flutter_ffmpeg supports the pipe protocol. Would you have an example of writing ffmpeg output to a pipe and reading from the pipe in dart code? Is that possible? |
Well, the first part of your question is answered in your link about pipes. The following command writes its output into a pipe.
But the second part, reading from the pipe in dart code, is very difficult. So I think Parent library, I can implement |
Hello, |
Reading a named pipe is the same as reading a file. In fact, named pipes look like files on the file system but they do not reside on the file system, their size is always 0 and can only be read once.
Well, I don't want to maintain another dart package. That's the main reason. Also, forcing a user to install another package don't look like a good design. |
Hello, |
There is a new API method called
|
Thanks! I tried using it and it seems to be working insofar as ffmpeg is writing to the created pipe when I read from it using cat in the terminal (from adb shell, run-as myapp, then cat mf_pipe_1). void readPipe(pipeName) async {
var file = File(pipeName);
var stream = file.openRead();
stream.listen((e) {
print(e.length.toString() + "\n");
}, onError: (e){
print(e);
});
}
String pipeName = await ffmpeg.registerNewFFmpegPipe();
var arguments = ["-y", "-i", audioFilePath, "-f", "s16le", "-ac", "1", "-c:a", "pcm_s16le", pipeName];
compute(readPipe, pipeName);
// wait for the isolate to spawn
await Future.delayed(Duration(seconds: 1));
await ffmpeg.executeWithArguments(arguments); But that last call blocks and nothing is received in the listening isolate. |
Actually this seems to be caused by this bug: dart-lang/sdk#32191 |
Currently,
getLastCommandOutput()
returns ffmpeg's error output, but AFAIK there is no way to get the standard (raw) output. This would be useful in order to convert a file to a memory buffer instead of having to write it to a temporary file just to read the file again.The text was updated successfully, but these errors were encountered: