From 28e88e77d098b44eb30374ce7c2fce99ad3acbda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Hern=C3=B8=20Gabrielli?= Date: Wed, 24 Jun 2020 03:05:43 +0200 Subject: [PATCH] Adapted the code to transcode video & minor edits Edited the gitignore for jetbarains Edited the README to remove the version number --- .gitignore | 5 +++-- README.md | 2 +- convert.py | 26 +++++++++++++------------- 3 files changed, 17 insertions(+), 16 deletions(-) mode change 100644 => 100755 convert.py diff --git a/.gitignore b/.gitignore index 05c333a..7c2361e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ -ImagesIn -ImagesOut +VideosIn +VideosOut +.idea diff --git a/README.md b/README.md index 0448d1c..7816fb1 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Mass video transcode 1.0 +# Mass video transcode This is a simple python tool to transcode multiple video files at once ## How to use diff --git a/convert.py b/convert.py old mode 100644 new mode 100755 index a55d447..6fc22ca --- a/convert.py +++ b/convert.py @@ -5,25 +5,25 @@ from os import listdir, system from os.path import isfile, join # Set the in and out folders -InFolder="ImagesIn" -OutFolder="ImagesOut" +InFolder="VideosIn" +OutFolder="VideosOut" + +# Chose actions for subs, audio, and audio +SubtitleAction = "copy" +AudioAction = "libvorbis" +VideoAction = "hevc_nvenc" # Make a list with all the files in the appropriate folder onlyfiles = [f for f in listdir(InFolder) if isfile(join(InFolder, f))] # Check file type and do the appropriate action for f in onlyfiles: - if f[-4:] == ".mp4": - print(f + " is an mp4 file, converting to GIF.") - # Convert to GIF - system("ffmpeg.exe -i \"" + InFolder + "\\" + f + "\" -nostats -loglevel 0 \"" + OutFolder + "\\" + f[:-4] + ".gif\"") - elif f[-5:] == ".webm": - print(f + " is a WebM file, converting to GIF.") - # Convert to GIF - system("ffmpeg.exe -i \"" + InFolder + "\\" + f + "\" -nostats -loglevel 0 \"" + OutFolder + "\\" + f[:-5] + ".gif\"") - else: - print(f + " is not an mp4 or WebM file, copying image.") - system("copy /V \"" + InFolder + "\\" + f + "\" \"" + OutFolder + "\\" + f + "\"") + 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.")