Skip to content

Commit

Permalink
updated
Browse files Browse the repository at this point in the history
  • Loading branch information
SamuraiPolix committed Jun 29, 2023
1 parent 2f6aa73 commit 394cdee
Show file tree
Hide file tree
Showing 12 changed files with 1,145 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .idea/VideoMaker.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified __pycache__/Fonts.cpython-310.pyc
Binary file not shown.
Binary file modified __pycache__/ffmpeg.cpython-310.pyc
Binary file not shown.
Binary file modified __pycache__/json_handler.cpython-310.pyc
Binary file not shown.
Binary file modified __pycache__/verse_handler.cpython-310.pyc
Binary file not shown.
24 changes: 18 additions & 6 deletions ffmpeg.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
import random
import subprocess
import re
import sys
import time
import json_handler
import verse_handler
import Fonts
import cv2



def create_dirs(output_folder, customer_name, posts=True):
# create a folder for this customer if it doesn't exist
output_path = f"{output_folder}/{customer_name}"
Expand Down Expand Up @@ -61,8 +63,13 @@ def create_videos(video_folder, audio_folder, json_file, fonts_dir, output_folde
spreadsheet_col2 = list()
spreadsheet_col3 = list()

estimated_runtime = get_avg_runtime('runtime.pk') * number_of_videos
print(f"Estimated run time: " + estimated_runtime / 60 + " minutes = " + estimated_runtime / 60 / 60 + " hours.")
estimated_runtime = round(get_avg_runtime('runtime.pk') * number_of_videos, 2)
# seconds
print(f"\033[0;32mEstimated run time: ", round(estimated_runtime, 2), " seconds\033[0m")
if round(estimated_runtime, 2) > 60: # minutes
print("\033[0;32m = ", round(estimated_runtime/60, 2), " minutes\033[0m")
if round(estimated_runtime/60, 2) > 60: # hours
print("\033[0;32m = ", round((estimated_runtime / 60) / 60, 2), " hours!\033[0m")

for i in range(number_of_videos):
start_time = time.time()
Expand Down Expand Up @@ -167,7 +174,7 @@ def create_video(text_verse, text_source, text_source_font, text_source_for_imag
text_source = text_source.replace(':', '\:')
output_path += f"/{file_name}"
# # FFMPEG command to overlay images and text onto input video
ffmpeg_command = (f'ffmpeg -y -loop 1 -i "{image_file}" -i "{audio_file}" '
ffmpeg_command = (f'ffmpeg -loglevel error -stats -y -loop 1 -i "{image_file}" -i "{audio_file}" '
f'-i "{video_file}" -i "{created_verse_image}" -r 24 -filter_complex '
f'"[2:v][0:v]overlay=(W-w)/2:{image_y}[v1]; '
# f'[v1]drawtext=fontfile={selected_font}:text=\'{text_verse}\':x=(w-text_w)/2:y=(h-text_h)/2:fontsize=60:fontcolor=white:'
Expand All @@ -176,7 +183,6 @@ def create_video(text_verse, text_source, text_source_font, text_source_for_imag
f'enable=\'between(t,{text_start_time},{video_duration})\'[v2]; '
f'[v2][3:v]overlay=(W-w)/2:{image_text_source_y}:enable=\'between(t,{text_start_time},{video_duration})\'[v3]" '
f'-t {video_duration} -map "[v3]" -map 1:a -c:v libx264 -preset veryfast -crf 18 -c:a copy "{output_path}"')

# WITHOUT LOGO
# ffmpeg_command = (f'ffmpeg -y -i "{audio_file}" '
# f'-i "{video_file}" -i "{created_verse_image}" -r 24 -filter_complex '
Expand All @@ -188,9 +194,15 @@ def create_video(text_verse, text_source, text_source_font, text_source_for_imag
# f'-t {video_duration} -map "[v2]" -map 0:a -c:v libx264 -preset veryfast -crf 18 -c:a copy "{output_path}"')

# Run FFMPEG command
subprocess.call(ffmpeg_command, shell=True)
try:
subprocess.check_call(ffmpeg_command, shell=True)
except subprocess.CalledProcessError as e:
# Handle the exception here
print(f"An error occurred: {e}")
sys.exit()


# if posts:
# if posts:
# verse_handler.create_post_images(video_path=output_path, output_folder=output_path.strip(f"/{file_name}"),
# verse_image_path=created_verse_image, text_source=text_source)

Expand Down
11 changes: 5 additions & 6 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@
from Fonts import Fonts

# Define the paths and values to everything
number_of_videos = 2
number_of_videos = 66
project_dir = os.getcwd().replace("\\", "/")

video_folder = f"{project_dir}/videos"
# video_folder = "E:/Bots/VideoMaker/videos/caribbean/darken0.4"
audio_folder = f"{project_dir}/audio"
json_file = f"{project_dir}/sources/verses_data/nvenlightenment_data.json"
json_file = f"{project_dir}/sources/verses_data/EverythinGod_data.json"
fonts_dir = f"{project_dir}/sources/fonts"
output_folder = f"{project_dir}/customers"
text_source_font = f'{project_dir}/sources/MouldyCheeseRegular-WyMWG.ttf'.replace(":/", "\:/")
image_file = f"{project_dir}/sources/nvenlightenment4.png"
customer_name = "nvenlightenment"
image_file = f"{project_dir}/sources/EverythinGodYT.png"
customer_name = "EverythinGod_NEW"
verse_text_image_path = f"{project_dir}/verse_images/{customer_name}"
fonts_paths = [f'{project_dir}/sources/fonts/CoffeeJellyUmai.ttf', f'{project_dir}/sources/fonts/CourierprimecodeRegular.ttf', f'{project_dir}/sources/fonts/EbGaramond08Regular-2mWe.ttf', f'{project_dir}/sources/fonts/FlowersSunday.otf', f'{project_dir}/sources/fonts/GreenTeaJelly.ttf', f'{project_dir}/sources/fonts/HeyMarch.ttf', f'{project_dir}/sources/fonts/Hugamour.ttf', f'{project_dir}/sources/fonts/LetsCoffee.otf', f'{project_dir}/sources/fonts/Lightning Script.ttf', f'{project_dir}/sources/fonts/LikeSlim.ttf', f'{project_dir}/sources/fonts/PineappleDays.ttf', f'{project_dir}/sources/fonts/SunnySpellsBasicRegular.ttf', f'{project_dir}/sources/fonts/TakeCoffee.ttf', f'{project_dir}/sources/fonts/WantCoffee.ttf']
fonts_sizes = [95, 70, 70, 65, 85, 75, 73, 50, 85, 75, 52, 87, 50, 65]
Expand All @@ -26,8 +26,7 @@


if __name__ == "__main__":
# fonts = Fonts(fonts_paths, fonts_sizes, fonts_maxcharsline)
fonts = Fonts([f'{project_dir}/sources/fonts/PermanentMarker-Regular.ttf'], [55], [35])
fonts = Fonts(fonts_paths, fonts_sizes, fonts_maxcharsline)
'''
customer_names = list()
json_file = list()
Expand Down
Binary file added runtime.pk
Binary file not shown.
Binary file added sources/everythingodYT.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified sources/logo.psd
Binary file not shown.
Loading

0 comments on commit 394cdee

Please sign in to comment.