Reputation: 3739
I want to use ffmpeg to convert video packets to mjpeg, and ideally, I want to pipe in the gob packet and receive the output via pipe also.
I'm using a C# process to call ffmpeg like this:
-f h264 -i pipe: -an -f mjpeg -q:v 1 pipe:
I pipe in the source data stream using the process .StandardInput.BaseStream and get the returned data from .StandardOutput.BaseStream.
The issue is, FFmpeg doesn't send data. It sits, apparently waiting. No errors. Nothing gets written to StandardOutput.
If I try each pipe on its own, it works fine. These work:
a) passing in a source file location and getting the returned frame data via pipe (bytes are written to StandardOutput)
b) passing in source bytes via pipe and asking Ffmpeg to save result to file
This doesn't work:
c) piping in data, and getting data out via pipe.
From a previous answer from @nmaier to this question (Can I use ffmpeg to output jpegs to a memory stream instead of a file) I think pipe-in/pipe-out should work. But it doesn't.
What am I doing wrong?
Thanks.
Upvotes: 2
Views: 3434
Reputation: 544
There seems to be a caveat with the use of multiple pipes / multiple directions in one program. Maybe there's some multi threading required which you didn't implement so far?
When googling (try "windows anonymous pipe wait until termination" or "windows anonymous pipe wait until terminate") I found this: http://blogs.msdn.com/b/oldnewthing/archive/2011/07/07/10183884.aspx
This article is about possible deadlocks when using pipes.
Upvotes: 1