diff --git a/.gitignore b/.gitignore index 7c2361e..923f4ec 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ -VideosIn -VideosOut +FilesIn +FilesOut .idea diff --git a/README.md b/README.md index 7816fb1..5ba4176 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ -# Mass video transcode -This is a simple python tool to transcode multiple video files at once +# Mass file transcode +This is a simple python tool to transcode multiple files at once. ## How to use -1. Put the things you want to convert in the folder named "ImagesIn" +1. Put the things you want to convert in the folder named "FilesIn" 2. Doubble click the file called "convert" or "convert.py" -3. Once the cmd windows closes the converted files should be in the "ImagesOut" folder. +3. Once the cmd windows closes the converted files should be in the "FilesOut" folder. diff --git a/convert.py b/convert.py index 6fc22ca..830c8e6 100755 --- a/convert.py +++ b/convert.py @@ -5,13 +5,14 @@ from os import listdir, system from os.path import isfile, join # Set the in and out folders -InFolder="VideosIn" -OutFolder="VideosOut" +InFolder="FilesIn" +OutFolder="FilesOut" -# Chose actions for subs, audio, and audio +# Chose actions for subs, video, audio, and images SubtitleAction = "copy" AudioAction = "libvorbis" -VideoAction = "hevc_nvenc" +VideoAction = "h264_nvenc" +ImageAction = "jpeg" # Make a list with all the files in the appropriate folder onlyfiles = [f for f in listdir(InFolder) if isfile(join(InFolder, f))] @@ -19,11 +20,17 @@ 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 - OutFilePath = "./" + OutFolder + "/" + f - if f[-4:] == ".mkv": - print(f + " is an mkv file, transcoding...") + if f[-4:] == ".mkv" or f[-4:] == ".mp4" or f[-4:] == ".m4a": + 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 + "'") + system("ffmpeg -loglevel 0 -i '" + InFilePath + "' -c:s " + SubtitleAction + " -c:a " + AudioAction + " -c:v " + VideoAction + " '" + OutFilePath + "' && rm '" + InFilePath + "'") + + if f[-5:] == ".webp": + print(f + " is a " + f[-4:] + " file, converting...") + OutFilePath = "./" + OutFolder + "/" + f[:-4] + ImageAction + # Convert + system("convert '" + InFilePath + "' '" + OutFilePath + "' && rm '" + InFilePath + "'") # Print status message print("That was all the files.")