It now copies files that aren't WebM or mp4 to the output folder.
Changed to using variables for input and output folder instead of hardcoding it in. Added more comments
This commit is contained in:
parent
1f932b8370
commit
add0cf3208
30
convert.py
30
convert.py
@ -1,24 +1,32 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
|
||||
# Import the required libraries
|
||||
from os import listdir, system
|
||||
from os.path import isfile, join
|
||||
|
||||
mypath="ImagesIn"
|
||||
# Set the in and out folders
|
||||
InFolder="ImagesIn"
|
||||
OutFolder="ImagesOut"
|
||||
|
||||
onlyfiles = [f for f in listdir(mypath) if isfile(join(mypath, f))]
|
||||
# Make a list with all the files in the appropriate folder
|
||||
onlyfiles = [f for f in listdir(InFolder) if isfile(join(InFolder, f))]
|
||||
|
||||
#print("Here are the files in the Images folder")
|
||||
# Check file type and do the appropriate action
|
||||
for f in onlyfiles:
|
||||
# print(f)
|
||||
# print("Converting " + f + " from WebM to GIF.")
|
||||
# system("ffmpeg.exe -i \"ImagesIn\\" + f + "\" \"ImagesOut\\" + f + ".gif\"")
|
||||
print(f[-4:])
|
||||
if f[-4:] == ".mp4":
|
||||
print(f + " is an mp4 file, converting to GIF.")
|
||||
system("ffmpeg.exe -i \"ImagesIn\\" + f + "\" \"ImagesOut\\" + f[:-4] + ".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.")
|
||||
system("ffmpeg.exe -i \"ImagesIn\\" + f + "\" \"ImagesOut\\" + f[:-5] + ".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 + "\"")
|
||||
|
||||
#print("And that was all the files.")
|
||||
# Print status message
|
||||
print("That was all the files.")
|
||||
|
||||
# Thank the user
|
||||
print("Thank you for using my tool!")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user