More options
This commit is contained in:
parent
47134245f5
commit
05269f3284
27
convert.py
27
convert.py
@ -9,6 +9,7 @@ InFolder="FilesIn"
|
||||
OutFolder="FilesOut"
|
||||
|
||||
# Chose actions for subs, video, audio, and images
|
||||
handbrake = True
|
||||
SubtitleAction = "copy"
|
||||
AudioAction = "libvorbis"
|
||||
VideoAction = "h264_nvenc"
|
||||
@ -20,17 +21,37 @@ onlyfiles = [f for f in listdir(InFolder) if isfile(join(InFolder, f))]
|
||||
# Check file type and do the appropriate action
|
||||
for f in onlyfiles:
|
||||
InFilePath = "./" + InFolder + "/" + f
|
||||
if f[-4:] == ".mkv" or f[-4:] == ".mp4" or f[-4:] == ".m4a":
|
||||
|
||||
# Video
|
||||
if f[-4:] == ".mkv" or f[-4:] == ".mp4":
|
||||
print(f + " is a " + f[-3:] + " file, transcoding...")
|
||||
OutFilePath = "./" + OutFolder + "/" + f[:-4] + ".mkv"
|
||||
# Transcode
|
||||
system("ffmpeg -loglevel 0 -i '" + InFilePath + "' -c:s " + SubtitleAction + " -c:a " + AudioAction + " -c:v " + VideoAction + " '" + OutFilePath + "' && rm '" + InFilePath + "'")
|
||||
if handbrake:
|
||||
system("HandBrakeCLI -i \"" + InFilePath + "\" -o \"" + OutFilePath + "\" -e nvenc_h264 -q 22 -E vorbis -s 1 --subtitle-default none --verbose 0 && rm \"" + InFilePath + "\"")
|
||||
#system("HandBrakeCLI -i \"" + InFilePath + "\" -o \"" + OutFilePath + "\" -e nvenc_h264 -q 22 -E vorbis --all-audio --all-subtitles --subtitle-default none --verbose 0 && rm \"" + InFilePath + "\"")
|
||||
else:
|
||||
system("ffmpeg -loglevel 0 -i \"" + InFilePath + "\" -c:s " + SubtitleAction + " -c:a " + AudioAction + " -c:v " + VideoAction + " \"" + OutFilePath + "\" && rm \"" + InFilePath + "\"")
|
||||
|
||||
# Audio
|
||||
if f[-5:] == ".opus":
|
||||
print(f + " is a " + f[-4:] + " file, converting...")
|
||||
OutFilePath = "./" + OutFolder + "/" + f[:-5] + ".ogg"
|
||||
# Transcode
|
||||
system("ffmpeg -loglevel 0 -i \"" + InFilePath + "\" -c:a " + AudioAction + " \"" + OutFilePath + "\" && rm \"" + InFilePath + "\"")
|
||||
|
||||
if f[-4:] == ".m4a":
|
||||
print(f + " is a " + f[-3:] + " file, converting...")
|
||||
OutFilePath = "./" + OutFolder + "/" + f[:-4] + ".ogg"
|
||||
# Transcode
|
||||
system("ffmpeg -loglevel 0 -i \"" + InFilePath + "\" -c:a " + AudioAction + " \"" + OutFilePath + "\" && rm \"" + InFilePath + "\"")
|
||||
|
||||
# Images
|
||||
if f[-5:] == ".webp":
|
||||
print(f + " is a " + f[-4:] + " file, converting...")
|
||||
OutFilePath = "./" + OutFolder + "/" + f[:-4] + ImageAction
|
||||
# Convert
|
||||
system("convert '" + InFilePath + "' '" + OutFilePath + "' && rm '" + InFilePath + "'")
|
||||
system("convert \"" + InFilePath + "\" \"" + OutFilePath + "\" && rm \"" + InFilePath + "\"")
|
||||
|
||||
# Print status message
|
||||
print("That was all the files.")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user