mass-video-transcode/convert.py

33 lines
970 B
Python
Raw Normal View History

2020-05-08 13:32:23 +00:00
#!/usr/bin/python3
# Import the required libraries
2020-05-08 13:32:23 +00:00
from os import listdir, system
from os.path import isfile, join
# Set the in and out folders
InFolder="VideosIn"
OutFolder="VideosOut"
# Chose actions for subs, audio, and audio
SubtitleAction = "copy"
AudioAction = "libvorbis"
VideoAction = "hevc_nvenc"
2020-05-08 13:32:23 +00:00
# Make a list with all the files in the appropriate folder
onlyfiles = [f for f in listdir(InFolder) if isfile(join(InFolder, f))]
2020-05-08 13:32:23 +00:00
# Check file type and do the appropriate action
2020-05-08 13:32:23 +00:00
for f in onlyfiles:
InFilePath = "./" + InFolder + "/" + f
OutFilePath = "./" + OutFolder + "/" + f
if f[-4:] == ".mkv":
print(f + " is an mkv file, transcoding...")
# Transcode
system("ffmpeg -loglevel 0 -i '" + InFilePath + "' -c:s " + SubtitleAction + " -c:a " + AudioAction + " -c:v " + VideoAction + " '" + OutFilePath + "'")
# Print status message
print("That was all the files.")
2020-05-08 13:32:23 +00:00
# Thank the user
print("Thank you for using my tool!")