added custom date and time option
This commit is contained in:
parent
0cc9cc2813
commit
8788843458
8
main.py
8
main.py
|
@ -22,6 +22,7 @@ parser.add_argument("-v", "--version", help="show program version", action="stor
|
||||||
parser.add_argument("-i", "--input")
|
parser.add_argument("-i", "--input")
|
||||||
parser.add_argument("-o", "--output", help="Output for specifying output video")
|
parser.add_argument("-o", "--output", help="Output for specifying output video")
|
||||||
parser.add_argument("-d","--date",help="Custom Date in yyyy/mm/dd format. e.g 2020/5/14")
|
parser.add_argument("-d","--date",help="Custom Date in yyyy/mm/dd format. e.g 2020/5/14")
|
||||||
|
parser.add_argument("-t","--time",help="Custom Time in HH:MM format. e.g 11:23")
|
||||||
|
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
@ -30,6 +31,7 @@ music = False
|
||||||
picture = False
|
picture = False
|
||||||
video = False
|
video = False
|
||||||
date = None
|
date = None
|
||||||
|
time = None
|
||||||
|
|
||||||
if args.version:
|
if args.version:
|
||||||
print("vaporwave generator 旺育栄", version)
|
print("vaporwave generator 旺育栄", version)
|
||||||
|
@ -46,6 +48,8 @@ if args.output:
|
||||||
outfile = args.output
|
outfile = args.output
|
||||||
if args.date:
|
if args.date:
|
||||||
date = args.date
|
date = args.date
|
||||||
|
if args.time:
|
||||||
|
time = args.time
|
||||||
else:
|
else:
|
||||||
parser.print_help()
|
parser.print_help()
|
||||||
exit
|
exit
|
||||||
|
@ -180,6 +184,6 @@ if music:
|
||||||
name, title = download_file(query)
|
name, title = download_file(query)
|
||||||
gen_vapor(name, title)
|
gen_vapor(name, title)
|
||||||
elif picture:
|
elif picture:
|
||||||
generateVHSStyle(query, "out.jpg",date=date)
|
generateVHSStyle(query, "out.jpg",date=date,time=time)
|
||||||
elif video:
|
elif video:
|
||||||
VHS_Vid(query, outfile)
|
VHS_Vid(query, outfile,date=date,time=time)
|
||||||
|
|
|
@ -8,6 +8,7 @@ import imageio
|
||||||
import random
|
import random
|
||||||
from math import floor
|
from math import floor
|
||||||
import os
|
import os
|
||||||
|
import logzero
|
||||||
from logzero import logger
|
from logzero import logger
|
||||||
import random
|
import random
|
||||||
|
|
||||||
|
@ -98,14 +99,15 @@ def mod_image_repeat_rows(
|
||||||
img.save(out_name)
|
img.save(out_name)
|
||||||
|
|
||||||
|
|
||||||
def add_date(img_path, out_name="image.jpg", bottom_offset=0,date=None,time=None):
|
def add_date(img_path, out_name="image.jpg", bottom_offset=0,date=None,time="00:00"):
|
||||||
if date==None:
|
if date==None:
|
||||||
date_obj = datetime.now()
|
date_obj = datetime.now()
|
||||||
date_str_1 = date_obj.strftime("%p %H:%M")
|
date_str_1 = date_obj.strftime("%p %H:%M")
|
||||||
date_str_2 = date_obj.strftime("%b. %d %Y")
|
date_str_2 = date_obj.strftime("%b. %d %Y")
|
||||||
else:
|
else:
|
||||||
date_obj = datetime.strptime(date, '%Y/%m/%d')
|
date_obj = datetime.strptime(date, '%Y/%m/%d')
|
||||||
date_str_1 = date_obj.strftime("%p %H:%M")
|
date_obj2 = datetime.strptime(time,'%H:%M')
|
||||||
|
date_str_1 = date_obj2.strftime("%p %H:%M")
|
||||||
date_str_2 = date_obj.strftime("%b. %d %Y")
|
date_str_2 = date_obj.strftime("%b. %d %Y")
|
||||||
corner_offset = 50
|
corner_offset = 50
|
||||||
img = Image.open(img_path)
|
img = Image.open(img_path)
|
||||||
|
@ -155,40 +157,28 @@ if __name__ == "__main__":
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
def generateVHSStyle(infile, outfile, silence=False,date=None):
|
def generateVHSStyle(infile, outfile, verbose=True,date=None,time="00:00"):
|
||||||
if silence:
|
if not verbose:
|
||||||
cut_rows = bool(random.getrandbits(1))
|
logzero.loglevel(level=0)
|
||||||
offset = random.choice([0, 5, 10])
|
cut_rows = bool(random.getrandbits(1))
|
||||||
offset_hue(infile, "saturated.jpg")
|
offset = random.choice([0, 5, 10, 15, 20, 25])
|
||||||
if cut_rows:
|
logger.info("Saturating the image")
|
||||||
mod_image_repeat_rows("saturated.jpg", 0.012, 50, 10, True, "shifted.jpg")
|
offset_hue(infile, "saturated.jpg")
|
||||||
else:
|
if cut_rows:
|
||||||
mod_image_repeat_rows("saturated.jpg", 0, 0, 0, True, "shifted.jpg")
|
logger.info("Shifting the image")
|
||||||
add_date("shifted.jpg", "noisy.jpg",date=date)
|
mod_image_repeat_rows("saturated.jpg", 0.012, 50, 10, True, "shifted.jpg")
|
||||||
add_date("noisy.jpg", outfile, bottom_offset=offset)
|
|
||||||
os.remove("shifted.jpg")
|
|
||||||
os.remove("saturated.jpg")
|
|
||||||
os.remove("noisy.jpg")
|
|
||||||
else:
|
else:
|
||||||
cut_rows = bool(random.getrandbits(1))
|
logger.info("Not applying lines effect")
|
||||||
offset = random.choice([0, 5, 10, 15, 20, 25])
|
mod_image_repeat_rows("saturated.jpg", 0, 0, 0, True, "shifted.jpg")
|
||||||
logger.info("Saturating the image")
|
logger.info("Adding noise")
|
||||||
offset_hue(infile, "saturated.jpg")
|
add_date("shifted.jpg", "noisy.jpg",date=date,time=time)
|
||||||
if cut_rows:
|
logger.info("Adding text")
|
||||||
logger.info("Shifting the image")
|
add_date("noisy.jpg", outfile, bottom_offset=offset,date=date,time=time)
|
||||||
mod_image_repeat_rows("saturated.jpg", 0.012, 50, 10, True, "shifted.jpg")
|
logger.info("Generated Image")
|
||||||
else:
|
logger.info("Removing residual files")
|
||||||
logger.info("Not applying lines effect")
|
os.remove("shifted.jpg")
|
||||||
mod_image_repeat_rows("saturated.jpg", 0, 0, 0, True, "shifted.jpg")
|
os.remove("saturated.jpg")
|
||||||
logger.info("Adding noise")
|
os.remove("noisy.jpg")
|
||||||
add_date("shifted.jpg", "noisy.jpg",date=date)
|
|
||||||
logger.info("Adding text")
|
|
||||||
add_date("noisy.jpg", outfile, bottom_offset=offset)
|
|
||||||
logger.info("Generated Image: out.jpg")
|
|
||||||
logger.info("Removing residual files")
|
|
||||||
os.remove("shifted.jpg")
|
|
||||||
os.remove("saturated.jpg")
|
|
||||||
os.remove("noisy.jpg")
|
|
||||||
|
|
||||||
|
|
||||||
# generateVHSStyle("s.jpg","o.jpg")
|
# generateVHSStyle("s.jpg","o.jpg")
|
||||||
|
|
|
@ -17,7 +17,7 @@ def SaveVid(path):
|
||||||
count += 1
|
count += 1
|
||||||
|
|
||||||
|
|
||||||
def Style(pathToFrames):
|
def Style(pathToFrames,date=None,time="00:00"):
|
||||||
files = [f for f in os.listdir(pathToFrames) if isfile(join(pathToFrames, f))]
|
files = [f for f in os.listdir(pathToFrames) if isfile(join(pathToFrames, f))]
|
||||||
count = 0
|
count = 0
|
||||||
for i in files:
|
for i in files:
|
||||||
|
@ -26,7 +26,7 @@ def Style(pathToFrames):
|
||||||
fi = pathToFrames + f
|
fi = pathToFrames + f
|
||||||
out = fi + ".jpg"
|
out = fi + ".jpg"
|
||||||
|
|
||||||
generateVHSStyle(fi, out, silence=True)
|
generateVHSStyle(fi, out, verbose=False,date=date,time=time)
|
||||||
os.rename(out, fi)
|
os.rename(out, fi)
|
||||||
print("--------")
|
print("--------")
|
||||||
print("On Frame: ")
|
print("On Frame: ")
|
||||||
|
@ -74,7 +74,7 @@ def generateVideo(outfile, path, infile):
|
||||||
out.release()
|
out.release()
|
||||||
|
|
||||||
|
|
||||||
def VHS_Vid(infile, outfile):
|
def VHS_Vid(infile, outfile,date=None,time="00:00"):
|
||||||
path = "./frames/"
|
path = "./frames/"
|
||||||
os.system("rm frames/*")
|
os.system("rm frames/*")
|
||||||
os.system("mkdir frames")
|
os.system("mkdir frames")
|
||||||
|
@ -84,7 +84,7 @@ def VHS_Vid(infile, outfile):
|
||||||
except:
|
except:
|
||||||
logger.debug("Extracted Frames")
|
logger.debug("Extracted Frames")
|
||||||
logger.info("Applying A E S T H E T I C S")
|
logger.info("Applying A E S T H E T I C S")
|
||||||
Style(path)
|
Style(path,date=date,time=time)
|
||||||
logger.info("Generating Vidio")
|
logger.info("Generating Vidio")
|
||||||
generateVideo("temp.mp4", path, infile)
|
generateVideo("temp.mp4", path, infile)
|
||||||
logger.info("Extracting audio of original video")
|
logger.info("Extracting audio of original video")
|
||||||
|
|
Loading…
Reference in New Issue