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:
parent
28e88e77d0
commit
47134245f5
4
.gitignore
vendored
4
.gitignore
vendored
@ -1,3 +1,3 @@
|
||||
VideosIn
|
||||
VideosOut
|
||||
FilesIn
|
||||
FilesOut
|
||||
.idea
|
||||
|
||||
@ -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.
|
||||
|
||||
23
convert.py
23
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.")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user