0
votes

In Pycharm, I have correctly set up an environment with ffmpeg: the project interpreter C:\Users\XYZ\AppData\Local\Programs\Python\Python37\python.exe contains, among others, the package ffmpeg. I can see that in the menu Settings then Project then Project Interpreter.

I would want to use this environment when I execute the following command, so ffmpeg will be found and execute correctly:

subprocess.call(
        ['ffmpeg', '-i', 'XYZ/XYZ.webm', '-stream_loop', '-1', '-i', 'XYZ/XYZ.wav',
         '-c:v', 'copy', '-shortest', '-fflags', '+shortest', '-max_interleave_delta', '100M',
         'XYZ/XYZ.webm']
        , cwd='C:/Users/XYZ/Desktop/ytg2/')

For the moment, however, the following error is triggered:

Traceback (most recent call last): File "C:/Users/XYZ/Desktop/ytg2/main.py", line 497, in , cwd='C:/Users/XYZ/Desktop/ytg2/') File "C:\Users\XYZ\AppData\Local\Programs\Python\Python37\lib\subprocess.py", line 323, in call with Popen(*popenargs, **kwargs) as p: File "C:\Users\XYZ\AppData\Local\Programs\Python\Python37\lib\subprocess.py", line 775, in init restore_signals, start_new_session) File "C:\Users\XYZ\AppData\Local\Programs\Python\Python37\lib\subprocess.py", line 1178, in _execute_child startupinfo) FileNotFoundError: [WinError 2] Le fichier spécifié est introuvable

Process finished with exit code 1

What should I do?

1
The error message seems to be saying ffmpeg is not installed or not on your PATH, in French. - tripleee
Because it sees a different PATH? Pure speculation; I don't use PyCharm, or Windows. - tripleee
At least for debugging, you can import os and examine os.environ['PATH'] in your script. If indeed it is incorrect, you can hardcode the path to ffmpeg (which by now you should know, even if you aren't revealing it) or maybe pass an augmented path to subprocess,call(), - tripleee
I'm vaguely guessing you have a Python package named ffmpeg which is displayed by PyCharm which is basically urelated to the external binary program ffmpeg. If the package is any good, you should probably use that instead of running the ffmpeg binary as a subprocess. Compare to using subprocess.call(['echo']) vs Python's built-in print. - tripleee

1 Answers

0
votes

I solved my problem by downloading ffmpeg for windows (https://ffmpeg.zeranoe.com/builds/). I unzipped it in a folder. Then I changed my subprocess call:

subprocess.call(
        ['C:/Users/XYZ/Downloads/ffmpeg/bin/ffmpeg.exe', '-i', 'XYZ/XYZ.webm', '-stream_loop', '-1', '-i', 'XYZ/XYZ.wav',
         '-c:v', 'copy', '-shortest', '-fflags', '+shortest', '-max_interleave_delta', '100M',
         'XYZ/XYZ.webm']
        , cwd='C:/Users/XYZ/Desktop/ytg2/')

Note the 'C:/Users/XYZ/Downloads/ffmpeg/bin/ffmpeg.exe'. Now, it works.