pipe

Pipe raw OpenCV images to FFmpeg

Pipe raw OpenCV images to FFmpeg Question: Here’s a fairly straightforward example of reading off a web cam using OpenCV’s python bindings: ”’capture.py”’ import cv, sys cap = cv.CaptureFromCAM(0) # 0 is for /dev/video0 while True : if not cv.GrabFrame(cap) : break frame = cv.RetrieveFrame(cap) sys.stdout.write( frame.tostring() ) Now I want to pipe the output …

Total answers: 5

Pipe subprocess standard output to a variable

Pipe subprocess standard output to a variable Question: I want to run a command in pythong, using the subprocess module, and store the output in a variable. However, I do not want the command’s output to be printed to the terminal. For this code: def storels(): a = subprocess.Popen(“ls”,shell=True) storels() I get the directory listing …

Total answers: 3

How to make a python script "pipeable" in bash?

How to make a python script "pipeable" in bash? Question: I wrote a script and I want it to be pipeable in bash. Something like: echo “1stArg” | myscript.py Is it possible? How? Asked By: gbr || Source Answers: Everything that reads from stdin is “pipeable”. Pipe simply redirects stdout of former program to the …

Total answers: 4

Communicate multiple times with a process without breaking the pipe?

Communicate multiple times with a process without breaking the pipe? Question: It’s not the first time I’m having this problem, and it’s really bugging me. Whenever I open a pipe using the Python subprocess module, I can only communicate with it once, as the documentation specifies: Read data from stdout and stderr, until end-of-file is …

Total answers: 4

How to diff file and output stream "on-the-fly"?

How to diff file and output stream "on-the-fly"? Question: I need to create a diff file using standard UNIX diff command with python subprocess module. The problem is that I must compare file and stream without creating tempopary file. I thought about using named pipes via os.mkfifo method, but didn’t reach any good result. Please, …

Total answers: 2

Retrieving the output of subprocess.call()

Retrieving the output of subprocess.call() Question: How can I get the output of a process run using subprocess.call()? Passing a StringIO.StringIO object to stdout gives this error: Traceback (most recent call last): File “<stdin>”, line 1, in <module> File “/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/subprocess.py”, line 444, in call return Popen(*popenargs, **kwargs).wait() File “/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/subprocess.py”, line 588, in __init__ errread, errwrite) …

Total answers: 7

blocks – send input to python subprocess pipeline

blocks – send input to python subprocess pipeline Question: I’m testing subprocesses pipelines with python. I’m aware that I can do what the programs below do in python directly, but that’s not the point. I just want to test the pipeline so I know how to use it. My system is Linux Ubuntu 9.04 with …

Total answers: 11

How do I use subprocess.Popen to connect multiple processes by pipes?

How do I use subprocess.Popen to connect multiple processes by pipes? Question: How do I execute the following shell command using the Python subprocess module? echo “input data” | awk -f script.awk | sort > outfile.txt The input data will come from a string, so I don’t actually need echo. I’ve got this far, can …

Total answers: 9