This question is related to my previous question: Converting raw frames into webm live stream
I want to pipe a video to ffmpeg and read it back through another pipe, but I cannot pipe the output of ffmpeg.exe
to a named pipe on windows.
My definition of the pipes in C#:
NamedPipeServerStream p_to_ffmpeg;
NamedPipeServerStream p_from_ffmpeg;
p_to_ffmpeg = new NamedPipeServerStream("to_ffmpeg", PipeDirection.Out, 1, PipeTransmissionMode.Byte);
p_from_ffmpeg = new NamedPipeServerStream("from_ffmpeg", PipeDirection.In, 1, PipeTransmissionMode.Byte);
And then I start ffmpeg.exe
in a separate process with the following options: -f rawvideo -vcodec rawvideo -video_size 656x492 -r 10 -pix_fmt rgb24 -i \\\\.\\pipe\\to_ffmpeg -c:v libvpx -pass 1 -f webm \\\\.\\pipe\\from_ffmpeg
ffmpeg.exe refuses to write to the pipe with the following error : File '\\\\.\\pipe\\from_ffmpeg' already exists. Overwrite ? [y/N]
File '\\\\.\\pipe\\from_ffmpeg' already exists. Overwrite ? [y/N]
When I replace the "output pipe" with a file name, it works like charm: -f rawvideo -vcodec rawvideo -video_size 656x492 -r 10 -pix_fmt rgb24 -i \\\\.\\pipe\\to_ffmpeg -c:v libvpx -pass 1 -f webm output.webm
How do I get ffmpeg to write to a named pipe in windows?
Edit: When I force to write to the pipe with ffmpeg's -y
option, I get the following error: Could not write header for output file #0 (incorrect codec parameters ?): Error number -32 occurred
It seems like the problem can be solved by adding the -y
option to the ffmpeg command and specifying a buffer size for the pipe.
My ffmpeg command (see aergistal's comment why I also removed the -pass 1
flag): -y -f rawvideo -vcodec rawvideo -video_size 656x492 -r 10 -pix_fmt rgb24 -i \\\\.\\pipe\\to_ffmpeg -c:v libvpx -f webm \\\\.\\pipe\\from_ffmpeg
And defining the named pipe as follows:
p_from_ffmpeg = new NamedPipeServerStream(pipename_from,
PipeDirection.In,
1,
PipeTransmissionMode.Byte,
System.IO.Pipes.PipeOptions.WriteThrough,
10000, 10000);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.