I'm trying to run ffmpeg on all the WAV files in a directory to convert them to mp3. This command works fine when I run it from the command-line, on my Fedora Linux machine:
/usr/bin/ffmpeg -i "Name With Spaces.wav" Name_With_Spaces.mp3
where Name With Spaces.wav is a file in the current directory. However, in Python 3.2 running in the same directory:
import os
files = os.listdir()
os.execl('/usr/bin/ffmpeg', '-i \"' + files[0] + '\"', files[0][:-4].replace(' ', '_') + '.mp3')
gives me the error (from ffmpeg): At least one input file must be specified. I don't see why this isn't working, because '-i \"' + files[0] + '\"' evaluates to -i "Name With Spaces.wav" and files[0][:-4].replace(' ', '_') + '.mp3' evaluates to Name_With_Spaces.mp3.
I've tried escaping spaces, using different quotation marks, using the full path (like /home/.../music/Name\ With\ Spaces.wav), and actually replacing the arguments with the real text, but nothing works. How can I get this to work?