I have two folders. Download folder and converted folder.
I want to convert files from .mkv to .mp4
import os
import boto3
import ffmpeg
from os import path, makedirs
downloadFolder = 'D:'+os.sep+'abc'+os.sep+'def'+os.sep+'downloaded'
convertedFolder = 'D:'+os.sep+'abc'+os.sep+'def'+os.sep+'converted'
#find the number of files in the Downloaded folder
initial_count = 0
for path in os.listdir(downloadFolder):
if os.path.isfile(os.path.join(downloadFolder, path)):
initial_count += 1
print("Files downloaded")
print(initial_count)
# convert all files from .mkv to .mp4
source_folder = downloadFolder
for file_name in os.listdir(source_folder):
try:
# construct full file path
source = source_folder + os.sep + file_name
print("source"+source)
destination = convertedFolder +os.sep +file_name
# copy only files
if os.path.isfile(source):
name, ext = os.path.splitext(file_name)
outFileName = convertedFolder + os.sep + name + '.mp4'
# convert .mkv into .mp4
ffmpeg.input(source).output(outFileName).run()
except Exception as e:
# print("Exception "+ key['Key'])
print("error")
print(e)
The below is the error i get because of ffmpeg
error
[WinError 2] The system cannot find the file specified
I also tried moviepy library. But couldnt solve. Please let me know a solution.
Thanks.