I made this script for compressing videos in Python 3:
import os
import sys
import subprocess
result = subprocess.run('ffmpeg -i output.mp4 -b 800k output.mp4')
print(result)
When I run the above, some error will come up like System cannot find the file specified
:
result = subprocess.run('ffmpeg -i output.mp4 -b 800k output.mp4')
File "C:\Program Files\Python37\lib\subprocess.py", line 488, in run
with Popen(*popenargs, **kwargs) as process:
File "C:\Program Files\Python37\lib\subprocess.py", line 800, in __init__
restore_signals, start_new_session)
File "C:\Program Files\Python37\lib\subprocess.py", line 1207, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified
Question: How to fix code for correct compressing of videos?
Nearly correct! It looks like the only module you need is subprocess. You should run your command in
run()
function. Try this: