Popen to get stdout and stderr for ffmpeg - No such file or directory ?
clp2 at rebertia.com
Tue Apr 19 01:36:06 CEST 2011
On Mon, Apr 18, 2011 at 4:07 PM, goldtech <goldtech at worldpost.com> wrote:
> 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
>>>> if os.path.exists(r'/home/giga/Desktop/Guitar1.flv'):
> print "exist"
> Also if I run the exact command (cmd3) in the terminal it works OK.
> Why is it not finding the file? Thanks, help appreciated.
Read The Fine Manual:
"On Unix, with shell=False (default): [...] 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.***" (emphasis added)
The system is interpreting the entire command string as the path to an
executable; obviously there's no directory named "ffmpeg -i ", so the
path is invalid, hence the error.
cmd3 = ['ffmpeg', '-i', '/home/giga/Desktop/Guitar1.flv']
More information about the Python-list