How can I stream to a named pipe

asked 2016-03-25 07:12:17 -0600

SiggyF gravatar image

I am trying to stream video to a named pipe (fifo). I do this by creating a fifo and then passing it as a filename to the VideoWriter constructor. This does not seem to be the right way to do it. How can I stream video to a fifo?

This is the code I used (in python)

import cv2
import os
import stat

# Create a fifo
path = '/tmp/c0'
os.unlink(path)
os.mkfifo(path)


# Make sure it's a fifo
mode = os.stat("/tmp/c0").st_mode
print(stat.S_ISFIFO(mode)) # True

# Open a videostream to the fifo
fourcc = cv2.VideoWriter_fourcc(*'MJPG')
stream = cv2.VideoWriter('/tmp/c0', fourcc, 20.0, (640,480))

# Is it still a fifo?
mode = os.stat("/tmp/c0").st_mode
print(stat.S_ISFIFO(mode)) # False (I was hoping for True here)
edit retag flag offensive close merge delete

Comments

1

i do not think, that this is possible at all.

berak gravatar imageberak ( 2016-03-25 07:15:28 -0600 )edit

@berak What makes you think that? I was just trying to achieve the same thing without luck :(

exhuma gravatar imageexhuma ( 2017-08-21 14:29:15 -0600 )edit