From 1fbb682faf0caea7da6177148a2bc536942ae2ff Mon Sep 17 00:00:00 2001 From: "Sebastian H. Gabrielli" Date: Fri, 19 May 2023 18:04:21 +0200 Subject: [PATCH] Added support for more files --- convert.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/convert.py b/convert.py index de65090..b81fb67 100755 --- a/convert.py +++ b/convert.py @@ -21,6 +21,7 @@ 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 + print("file: " + InFilePath) # Video if f[-4:] == ".mkv" or f[-4:] == ".mp4": @@ -38,13 +39,26 @@ for f in onlyfiles: 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 + "\"") + system("ffmpeg -loglevel 0 -vn -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 + "\"") + system("ffmpeg -loglevel 0 -vn -i \"" + InFilePath + "\" -c:a " + AudioAction + " \"" + OutFilePath + "\" && rm \"" + InFilePath + "\"") + + # If we run it through again, we convert the OGG to an MP3 + if f[-4:] == ".ogg": + print(f + " is a " + f[-3:] + " file, converting...") + OutFilePath = "./" + OutFolder + "/" + f[:-4] + ".mp3" + # Transcode + system("ffmpeg -loglevel 0 -vn -i \"" + InFilePath + "\" -c:a " + "libmp3lame" + " \"" + OutFilePath + "\" && rm \"" + InFilePath + "\"") + + if f[-5:] == ".webm": + print(f + " is a " + f[-4:] + " file, converting...") + OutFilePath = "./" + OutFolder + "/" + f[:-5] + ".ogg" + # Transcode + system("ffmpeg -loglevel 0 -vn -i \"" + InFilePath + "\" -c:a " + AudioAction + " \"" + OutFilePath + "\" && rm \"" + InFilePath + "\"") # Images if f[-5:] == ".webp":