Skip to content

Commit

Permalink
Update!
Browse files Browse the repository at this point in the history
Added Comments
  • Loading branch information
cool-guy-is-perfect authored Jun 28, 2022
1 parent 193e6b8 commit 3941542
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
#!/bin/python

# Import
import random
import audioread
import os
import joke_gen as test
import json

#Main class
class create:
def __init__(self,img):
def __init__(self,img): #Init
self.test = test
self.img = img
self.start = 0
self.end = 0
self.iterator1 = 1
def createAudio(self,aud1,aud2):
def createAudio(self,aud1,aud2): #create Audio
self.test.get()
self.audio_1 = aud1
self.audio_2 = aud2
self.test = test
def createText(self):
def createText(self): #create subtitle/text
self.subtitle = ""
self.quote = [test.data["setup"],"Reply: "+test.data["delivery"]]
for self.i in self.quote:
Expand All @@ -38,7 +41,7 @@ def createText(self):
self.file = open("subtitle.srt", "w") # create and oen for writing
self.file.write(self.subtitle)
self.file.close() #to change file access modes
def preProduce(self):
def preProduce(self): #Make initial Arrangements
self.duration_aud_1 = audioread.audio_open(f"process/{self.audio_1}").duration
self.duration_aud_2 = audioread.audio_open(f"process/{self.audio_2}").duration

Expand All @@ -47,7 +50,7 @@ def preProduce(self):

#change some
self.end = self.duration_aud_1
def createFile(self):
def createFile(self):#Final Create File
# create a file
os.system(f"""ffmpeg -loop 1 -y -i input/{self.img} -c:v libx264 -t {self.duration_aud_2 + self.duration_aud_1 + 1} -pix_fmt yuv420p -vf scale=1080:1920 process/out-beta.mp4""")
# apply overlay
Expand All @@ -58,10 +61,10 @@ def createFile(self):
os.system(f"""ffmpeg -y -i process/out-cache.mp4 -vf "subtitles=subtitle.srt:force_style='Alignment=10,Fontsize=18,PrimaryColour=&H0xFAEBD7&,FontName=DejaVu Serif'" -c:a copy process/out-beta.mp4""")
# add audio
os.system(f"""ffmpeg -y -i process/out-beta.mp4 -i process/audio-out.mp3 -map 0 -map 1:a -c:v copy -shortest out-main.mp4""")
def generate():

n = 1 #random.randint(0,4)
video = create(f"input.jpg")#add n to get a random image from input folder
def generate(): # For More:
n = 1 # n = random.randint(0,4)
video = create(f"input.jpg") # video = create(f"input{n}.jpg") #add n to get a random image from input folder
print(" Creating audio... ",end="")
video.createAudio("audio.mp3","audio2.mp3")
print("DONE \n Preproduce... ", end="")
Expand All @@ -73,4 +76,8 @@ def generate():
print("DONE \n\n\n")
print("Video file saved as out-main.mp4")

generate()
generate() #Call this function to generate a video

###############################################
# Made For Fun

0 comments on commit 3941542

Please sign in to comment.