Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -41,7 +41,6 @@ def step_2_render_video(video_path, df_edited):
|
|
| 41 |
chunk_size = 3
|
| 42 |
|
| 43 |
for i in range(0, len(words_list), chunk_size):
|
| 44 |
-
# تحديد المجموعة (3 كلمات)
|
| 45 |
current_chunk = words_list[i : i + chunk_size]
|
| 46 |
sentence = " ".join([str(r[0]) for r in current_chunk])
|
| 47 |
clean_sentence = reshape(sentence) + "\n "
|
|
@@ -50,11 +49,11 @@ def step_2_render_video(video_path, df_edited):
|
|
| 50 |
c_end = float(current_chunk[-1][2])
|
| 51 |
duration = c_end - c_start
|
| 52 |
|
| 53 |
-
# إنشاء النص
|
| 54 |
txt_clip = TextClip(
|
| 55 |
text=clean_sentence,
|
| 56 |
-
font_size=90,
|
| 57 |
-
color='yellow',
|
| 58 |
stroke_color='black',
|
| 59 |
stroke_width=2,
|
| 60 |
method='caption',
|
|
@@ -63,21 +62,22 @@ def step_2_render_video(video_path, df_edited):
|
|
| 63 |
text_align='center'
|
| 64 |
).with_start(c_start).with_duration(duration).with_position(('center', int(h * 0.75)))
|
| 65 |
|
| 66 |
-
# ---
|
| 67 |
-
#
|
| 68 |
-
def
|
| 69 |
-
|
| 70 |
-
|
|
|
|
| 71 |
return 1.0
|
| 72 |
|
| 73 |
-
# تطبيق الأ
|
| 74 |
-
animated_txt = txt_clip.
|
| 75 |
|
| 76 |
clips.append(animated_txt)
|
| 77 |
|
| 78 |
final_video = CompositeVideoClip(clips, size=(w, h))
|
| 79 |
-
final_video.write_videofile(output_path, codec="libx264", audio_codec="aac", fps=video.fps)
|
| 80 |
-
return output_path, "تم إنتاج الفيديو بأنيميشن
|
| 81 |
|
| 82 |
# --- بناء الواجهة (تصحيح ربط المخرجات) ---
|
| 83 |
with gr.Blocks() as app:
|
|
|
|
| 41 |
chunk_size = 3
|
| 42 |
|
| 43 |
for i in range(0, len(words_list), chunk_size):
|
|
|
|
| 44 |
current_chunk = words_list[i : i + chunk_size]
|
| 45 |
sentence = " ".join([str(r[0]) for r in current_chunk])
|
| 46 |
clean_sentence = reshape(sentence) + "\n "
|
|
|
|
| 49 |
c_end = float(current_chunk[-1][2])
|
| 50 |
duration = c_end - c_start
|
| 51 |
|
| 52 |
+
# إنشاء النص
|
| 53 |
txt_clip = TextClip(
|
| 54 |
text=clean_sentence,
|
| 55 |
+
font_size=90,
|
| 56 |
+
color='yellow',
|
| 57 |
stroke_color='black',
|
| 58 |
stroke_width=2,
|
| 59 |
method='caption',
|
|
|
|
| 62 |
text_align='center'
|
| 63 |
).with_start(c_start).with_duration(duration).with_position(('center', int(h * 0.75)))
|
| 64 |
|
| 65 |
+
# --- الأنيميشن المحترف (Zoom Pop) ---
|
| 66 |
+
# استخدام دالة resize المدمجة التي تقبل دالة زمنية
|
| 67 |
+
def zoom_effect(t):
|
| 68 |
+
# يبدأ من 80% من الحجم ويصل لـ 100% في أول 0.15 ثانية
|
| 69 |
+
if t < 0.15:
|
| 70 |
+
return 0.8 + (1.33 * t)
|
| 71 |
return 1.0
|
| 72 |
|
| 73 |
+
# تطبيق التأثير بطريقة متوافقة مع الإصدار الجديد
|
| 74 |
+
animated_txt = txt_clip.with_effects([lambda clip: clip.resize(zoom_effect)])
|
| 75 |
|
| 76 |
clips.append(animated_txt)
|
| 77 |
|
| 78 |
final_video = CompositeVideoClip(clips, size=(w, h))
|
| 79 |
+
final_video.write_videofile(output_path, codec="libx264", audio_codec="aac", fps=video.fps, logger=None)
|
| 80 |
+
return output_path, "تم إنتاج الفيديو بأنيميشن Pop-up بنجاح!"
|
| 81 |
|
| 82 |
# --- بناء الواجهة (تصحيح ربط المخرجات) ---
|
| 83 |
with gr.Blocks() as app:
|