I have a lot of .mkv files that I'm trying to convert to .mp4, so I decided to try and program a solution in python. After a few hours, trying to figure out how to copy the subfolders too, I gave up on it and decided to stick with converting individual subfolders, and then copying them over to another directory.
I've made a simple script, that should convert .mkv files that are in the same folder as the script. However, I keep getting this error:
FileNotFoundError: [WinError 2] The system cannot find the file specified
Here's my code:
import os
import ffmpeg
start_dir = os.getcwd()
def convert_to_mp4(mkv_file):
no_extension = str(os.path.splitext(mkv_file))
with_mp4 = no_extension + ".mp4"
ffmpeg.input(mkv_file).output(with_mp4).run()
print("Finished converting {}".format(no_extension))
for path, folder, files in os.walk(start_dir):
for file in files:
if file.endswith('.mkv'):
print("Found file: %s" % file)
convert_to_mp4(file)
else:
pass