I tried 3 methods to call ffmpeg from python, but it always blocks and doesn’t return any result.
However, if I execute it from shell, it works.
For eg:
/usr/bin/ffmpeg -y -i /tmp/uploadedfiles/movie8_15_10s.mpg -ar 1600 -ac 1 /tmp/uploadedfiles/movie8_15_10s.mpg.wav
this works.
However,
ffmpeg_command = "/usr/bin/ffmpeg -y -i test.wav testout.wav"
f_ffmpeg=os.popen(ffmpeg_command);
This makes the python hang.
You should use
subprocess.Popeninstead ofos.popen.In particular, to get same behaviour, you can run the process through a shell with
shell=Trueand gather the output fromstdoutandstderras follows:where
commandis the same command line you would write in a shell.