I am trying to convert a test.mp4 file to test.wav from python code using avconv. I am able to convert the test.mp4 to test.wmv using cmd line but when i run the same command from python its giving me following error :
line 103, in get_message_audio subprocess.call(cmdline) FileNotFoundError: [WinError 2] The system cannot find the file specified
The code i am using from python file is :
cmdline = ['avconv', '-i', 'test.mp4', '-vn', '-f', 'wav', 'test.wav']
subprocess.call(cmdline)
But when i run the same command from cmd it successfully runs and save the test.wav file.
cmd line = avconv -i test.mp4 -f wav test.wav
Note: I have added avconv to system variable. The python file and test.mp4 is in the same directory. I am running the cmd from the same directory as well.
My guess is that it is not finding the
avconvexecutable. I would suggest that you use the full absolute path toavconvin your command in Python. Another thing you can try is using a shell, by addingshell=Trueto yoursubprocess.call()call.In other words, do this and see if it helps:
I don't think it's the input file it can't find. It doesn't seem to be getting that far. At the point that
subprocess.call(cmdline)is failing,test.mp4andtest.wavare just strings being passed toavconv.My guess is that
avconvisn't in the PATH of the environment in which Python is running the command.shell=Truemight help that.