Popen to get stdout and stderr for ffmpeg - No such file or directory ?
rhodri at wildebst.demon.co.uk
Mon Apr 18 19:35:49 EDT 2011
On Tue, 19 Apr 2011 00:07:46 +0100, goldtech <goldtech at worldpost.com>
> Trying to learn how to run a linux command and get the stdout and
> stderr. I'm trying the following:
>>>> cmd3 = r'ffmpeg -i /home/giga/Desktop/Guitar1.flv'
>>>> p = Popen(cmd3, stdout=PIPE, stderr=PIPE)
> Traceback (most recent call last):
> File "<pyshell#73>", line 1, in <module>
> p = Popen(cmd3, stdout=PIPE, stderr=PIPE)
> File "/usr/lib/python2.6/subprocess.py", line 623, in __init__
> errread, errwrite)
> File "/usr/lib/python2.6/subprocess.py", line 1141, in
> raise child_exception
> OSError: [Errno 2] No such file or directory
This is something that catches everyone! From the Fine Manual
> On Unix, with shell=False (default): In this case, the Popen class
> uses os.execvp() to execute the child program. args should normally
> be a sequence. If a string is specified for args, it will be used
> as the name or path of the program to execute; this will only work
> if the program is being given no arguments.
What you actually want is more like:
p = Popen(('ffmpeg', '-i', '/home/giga/Desktop/Guitar1.flv'),
The manual gives you an example of using shlex to split a string
into tokens if you'd rather do it that way.
Rhodri James *-* Wildebeest Herder to the Masses
More information about the Python-list