Skip to content

Commit

Permalink
Merge pull request #1 from mexicancartel/main
Browse files Browse the repository at this point in the history
	modified:   main.py
  • Loading branch information
cool-guy-is-perfect authored Jun 28, 2022
2 parents 660cdbd + 968e2d9 commit 193e6b8
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 23 deletions.
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,25 @@ This is a short video maker .which generates videos of jokes. it uses `python` a
***



## Requirements:
#### ffmpeg.exe installed
#### ffmpeg installed
#### python installed
#### basic python modules


## Execution:
#### install ffmpeg.exe
#### install ffmpeg-python module
#### install gtts module for python(in addition you must have python modules:json,random,os,requests)
#### install ffmpeg
#### install required modules (gtts, requests, json, random). In command line you can use the command below
pip install -r requirements.txt
>
#### now run the main.py
#### Wait while the render is being completed
#### it probably takes 20-120s or more to generate a video file.
###### thanks :)





## Info:
Expand All @@ -28,3 +33,4 @@ This is a short video maker .which generates videos of jokes. it uses `python` a
#### the *additional folder* contains an overlay which applies a translucent look to the video.
#### the *input folder* contains a sample image which is used in the video.
#### Note:you can change the image in input folder as you like to change the background image of the video.

38 changes: 20 additions & 18 deletions main.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#!/bin/python

import random
import ffmpeg
import audioread
import os
import goke_gen as test
import joke_gen as test
import json
class create:
def __init__(self,img):
Expand Down Expand Up @@ -33,19 +35,13 @@ def createText(self):
self.start = self.end
self.end = self.end + self.duration_aud_2 +1
self.iterator1 += 1
self.file = open("subtitle.srt", "r+")
self.file.truncate(0)
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):
self.input_aud_1 = ffmpeg.probe(f"process/{self.audio_1}")
self.input_aud_2 = ffmpeg.probe(f"process/{self.audio_2}")
self.duration_aud_1 = self.input_aud_1['format']['duration']
self.duration_aud_1 = float(self.duration_aud_1)
self.duration_aud_1 = int(self.duration_aud_1)
self.duration_aud_2 = self.input_aud_2['format']['duration']
self.duration_aud_2 = float(self.duration_aud_2)
self.duration_aud_2 = int(self.duration_aud_2)
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

print(self.duration_aud_2 + self.duration_aud_1)


Expand All @@ -64,11 +60,17 @@ def createFile(self):
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
video.createAudio("audio.mp3","audio2.mp3")
video.preProduce()
video.createText()
video.createFile()
n = 1 #random.randint(0,4)
video = create(f"input.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="")
video.preProduce()
print("DONE \n Generating subtitles... ", end="")
video.createText()
print("DONE \n Generating video... ",end="")
video.createFile()
print("DONE \n\n\n")
print("Video file saved as out-main.mp4")

generate()
6 changes: 6 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
audioread
gtts
requests
json
random
os
1 change: 0 additions & 1 deletion subtitle.srt

This file was deleted.

0 comments on commit 193e6b8

Please sign in to comment.