Discussion:
[FFmpeg-user] Possible to use named pipe between ffmpeg and ffplay on Windows?
Paul Goins
2013-05-31 06:42:44 UTC
Permalink
Hi,

Let's say I have two named pipes: "\\.\pipe\piper_in" and "\\.\pipe\piper_out". The pipes are being
managed through an intermediate process, basically working as a poor man's mkfifo on Windows. The
intent is to have ffmpeg write to \\.\pipe\piper_in, and ffplay read from \\.\pipe\piper_out.

ffplay seems to work fine with this. I connect it first via:

ffplay -f rawvideo -pixel_format bgr24 -s 1280x720
-i \\.\pipe\piper_out

The problem comes when I try to run ffmpeg with the named pipe as
output.

Command line:

ffmpeg -f dshow -rtbufsize 1000000k -s 1280x720 -r 30
-i video="Logicool HD Webcam C310"
-f rawvideo -vcodec copy -an
\\.\pipe\piper_in

This results in the following:

File '\\.\pipe\piper_in' already exists. Overwrite ? [y/N] y
\\.\pipe\piper_in: No such file or directory

Basically: rather than writing to the pipe, ffmpeg attempts to create a new file.

Is there any way to make this work? Or is this sounding like a feature request for the devs?


Best Regards,
Paul Goins
Carl Eugen Hoyos
2013-05-31 09:11:54 UTC
Permalink
Post by Paul Goins
ffmpeg -f dshow -rtbufsize 1000000k -s 1280x720 -r 30
-i video="Logicool HD Webcam C310"
-f rawvideo -vcodec copy -an
\\.\pipe\piper_in
Does it work with pipe://pipe/piper_in ?

FFmpeg assumes piper_in is a file (that it overwrites)
if you don't specify anything else.

Carl Eugen
Maxim Kozlov
2013-05-31 10:18:38 UTC
Permalink
Try this command:

ffmpeg -f dshow -rtbufsize 1000000k -s 1280x720 -r 30 -i video="Logicool HD
Webcam C310" -an -c:v libx264 -q 0 -f h264 - | ffmpeg -f h264 -i - -c copy
-f mp4 c:\file.mp4 -f copy pipe:play | ffplay -i pipe:play

1st instance of ffmpeg will capture wideo from webcam, encodes it to x264
and sends to a pipe.
2nd instance of ffmpeg grabs stream from pipe, saves it to file and sends
stream to pipe:play
Paul Goins
2013-06-01 05:40:12 UTC
Permalink
Post by Maxim Kozlov
ffmpeg -f dshow -rtbufsize 1000000k -s 1280x720 -r 30 -i video="Logicool HD
Webcam C310" -an -c:v libx264 -q 0 -f h264 - | ffmpeg -f h264 -i - -c copy
-f mp4 c:\file.mp4 -f copy pipe:play | ffplay -i pipe:play
Doesn't work for me. It runs for awhile, all 3 processes are launched, but then it gives an error.

(other output excluded)
c:\file.mp4: Permission denied

I changed c:\file.mp4 to file.mp4, then I get:

Input #0, h264, from 'pipe:':
Duration: N/A, bitrate: N/A
Stream #0:0: Video: h264 (High 4:4:4 Predictive), yuv444p, 1280x720, 30 fps, 30 tbr, 1200k
tbn, 60 tbc
[NULL @ 0000000002e44500] Requested output format 'copy' is not a suitable output format
pipe:play: Invalid argument
pipe:play: Invalid data found when processing input

av_interleaved_write_frame(): Invalid argument

I think this example won't work for me.
Maxim Kozlov
2013-06-04 20:06:03 UTC
Permalink
My bad in command line.
Try this:

ffmpeg -f dshow -rtbufsize 1000000k -s 1280x720 -r 30 -i video="Logicool HD
Webcam C310" -an -c:v libx264 -q 0 -f h264 - | ffmpeg -f h264 -i - -an -c:v
copy -f mp4 file.mp4 -an -c:v copy -f h264 pipe:play | ffplay -i pipe:play
Paul Goins
2013-06-01 05:27:51 UTC
Permalink
Post by Carl Eugen Hoyos
Post by Paul Goins
ffmpeg -f dshow -rtbufsize 1000000k -s 1280x720 -r 30
-i video="Logicool HD Webcam C310"
-f rawvideo -vcodec copy -an
\\.\pipe\piper_in
Does it work with pipe://pipe/piper_in ?
Interesting; this was worth a try.
I definitely get different behavior.

I tried the following 4 ways:

pipe://pipe/piper_in
pipe://\\.\pipe\piper_in
pipe://piper_in
pipe://./pipe/piper_in

None of them connect to the pipe (the app managing the pipe tells when the pipe connects).
Instead, I get lots of stuff, presumably binary data, dumped to stdout; I then have to terminate the
process.
Loading...