Update app.py
Browse files
app.py
CHANGED
|
@@ -88,6 +88,7 @@ def get_available_fonts():
|
|
| 88 |
|
| 89 |
def preview_layout(
|
| 90 |
images,
|
|
|
|
| 91 |
arabic_font,
|
| 92 |
arabic_y,
|
| 93 |
translation_gap,
|
|
@@ -95,12 +96,52 @@ def preview_layout(
|
|
| 95 |
translation_font_size
|
| 96 |
):
|
| 97 |
|
| 98 |
-
if not images:
|
| 99 |
-
raise Exception(
|
|
|
|
|
|
|
| 100 |
|
| 101 |
preview_path = "temp/preview.jpg"
|
| 102 |
|
| 103 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 104 |
|
| 105 |
h, w = img.shape[:2]
|
| 106 |
|
|
@@ -391,6 +432,7 @@ Generate cinematic Quran video automatically.
|
|
| 391 |
fn=preview_layout,
|
| 392 |
inputs=[
|
| 393 |
images,
|
|
|
|
| 394 |
arabic_font,
|
| 395 |
arabic_y,
|
| 396 |
translation_gap,
|
|
|
|
| 88 |
|
| 89 |
def preview_layout(
|
| 90 |
images,
|
| 91 |
+
background_video,
|
| 92 |
arabic_font,
|
| 93 |
arabic_y,
|
| 94 |
translation_gap,
|
|
|
|
| 96 |
translation_font_size
|
| 97 |
):
|
| 98 |
|
| 99 |
+
if not images and not background_video:
|
| 100 |
+
raise Exception(
|
| 101 |
+
"Upload Images atau Background Video"
|
| 102 |
+
)
|
| 103 |
|
| 104 |
preview_path = "temp/preview.jpg"
|
| 105 |
|
| 106 |
+
# =========================
|
| 107 |
+
# IMAGE MODE
|
| 108 |
+
# =========================
|
| 109 |
+
|
| 110 |
+
if images:
|
| 111 |
+
|
| 112 |
+
img = cv2.imread(
|
| 113 |
+
images[0].name
|
| 114 |
+
)
|
| 115 |
+
|
| 116 |
+
# =========================
|
| 117 |
+
# VIDEO MODE
|
| 118 |
+
# =========================
|
| 119 |
+
|
| 120 |
+
else:
|
| 121 |
+
|
| 122 |
+
frame_path = (
|
| 123 |
+
"temp/frame.jpg"
|
| 124 |
+
)
|
| 125 |
+
|
| 126 |
+
subprocess.run(
|
| 127 |
+
[
|
| 128 |
+
"ffmpeg",
|
| 129 |
+
"-y",
|
| 130 |
+
|
| 131 |
+
"-i",
|
| 132 |
+
background_video,
|
| 133 |
+
|
| 134 |
+
"-vframes",
|
| 135 |
+
"1",
|
| 136 |
+
|
| 137 |
+
frame_path
|
| 138 |
+
],
|
| 139 |
+
check=True
|
| 140 |
+
)
|
| 141 |
+
|
| 142 |
+
img = cv2.imread(
|
| 143 |
+
frame_path
|
| 144 |
+
)
|
| 145 |
|
| 146 |
h, w = img.shape[:2]
|
| 147 |
|
|
|
|
| 432 |
fn=preview_layout,
|
| 433 |
inputs=[
|
| 434 |
images,
|
| 435 |
+
background_video,
|
| 436 |
arabic_font,
|
| 437 |
arabic_y,
|
| 438 |
translation_gap,
|