Added support for more filetypes

Renamed it from "mass file transcode" to "mass file transcode" due to the changing nature of the script
This commit is contained in:
sebgab 2021-04-14 21:58:22 +02:00
parent 28e88e77d0
commit 47134245f5
3 changed files with 21 additions and 14 deletions

4
.gitignore vendored
View File

@ -1,3 +1,3 @@
VideosIn FilesIn
VideosOut FilesOut
.idea .idea

View File

@ -1,7 +1,7 @@
# Mass video transcode # Mass file transcode
This is a simple python tool to transcode multiple video files at once This is a simple python tool to transcode multiple files at once.
## How to use ## 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" 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.

View File

@ -5,13 +5,14 @@ from os import listdir, system
from os.path import isfile, join from os.path import isfile, join
# Set the in and out folders # Set the in and out folders
InFolder="VideosIn" InFolder="FilesIn"
OutFolder="VideosOut" OutFolder="FilesOut"
# Chose actions for subs, audio, and audio # Chose actions for subs, video, audio, and images
SubtitleAction = "copy" SubtitleAction = "copy"
AudioAction = "libvorbis" AudioAction = "libvorbis"
VideoAction = "hevc_nvenc" VideoAction = "h264_nvenc"
ImageAction = "jpeg"
# Make a list with all the files in the appropriate folder # Make a list with all the files in the appropriate folder
onlyfiles = [f for f in listdir(InFolder) if isfile(join(InFolder, f))] 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 # Check file type and do the appropriate action
for f in onlyfiles: for f in onlyfiles:
InFilePath = "./" + InFolder + "/" + f InFilePath = "./" + InFolder + "/" + f
OutFilePath = "./" + OutFolder + "/" + f if f[-4:] == ".mkv" or f[-4:] == ".mp4" or f[-4:] == ".m4a":
if f[-4:] == ".mkv": print(f + " is a " + f[-3:] + " file, transcoding...")
print(f + " is an mkv file, transcoding...") OutFilePath = "./" + OutFolder + "/" + f[:-4] + ".mkv"
# Transcode # 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 status message
print("That was all the files.") print("That was all the files.")