Update app.py
Browse files
app.py
CHANGED
@@ -36,6 +36,7 @@ from transformers import pipeline
|
|
36 |
from transformers import AutoModelForImageSegmentation
|
37 |
from torchvision import transforms
|
38 |
|
|
|
39 |
# ββ moviepy import ββββββββββββββββββββββββββββββββββββββββββ
|
40 |
try:
|
41 |
# editor μλΈλͺ¨λμ΄ μμΌλ©΄ μ°μ μ¬μ©
|
@@ -43,12 +44,20 @@ try:
|
|
43 |
except ImportError:
|
44 |
from moviepy import VideoFileClip, concatenate_videoclips
|
45 |
|
46 |
-
# resize ν¨μ:
|
47 |
try:
|
48 |
-
from moviepy.video.fx.resize import resize
|
49 |
except ImportError:
|
50 |
-
|
51 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
|
53 |
from moviepy import (
|
54 |
ImageSequenceClip,
|
@@ -58,8 +67,7 @@ from moviepy import (
|
|
58 |
)
|
59 |
from moviepy.video.compositing.CompositeVideoClip import CompositeVideoClip
|
60 |
from moviepy.video.VideoClip import ColorClip
|
61 |
-
#
|
62 |
-
|
63 |
import time
|
64 |
from concurrent.futures import ThreadPoolExecutor
|
65 |
|
@@ -709,8 +717,18 @@ def merge_videos_with_audio(video_files, audio_file, audio_volume, output_fps):
|
|
709 |
adjusted_clips = []
|
710 |
for clip, size in zip(video_clips, clip_sizes):
|
711 |
if size != (target_width, target_height):
|
712 |
-
|
713 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
714 |
adjusted_clips.append(adjusted_clip)
|
715 |
else:
|
716 |
adjusted_clips.append(clip)
|
|
|
36 |
from transformers import AutoModelForImageSegmentation
|
37 |
from torchvision import transforms
|
38 |
|
39 |
+
|
40 |
# ββ moviepy import ββββββββββββββββββββββββββββββββββββββββββ
|
41 |
try:
|
42 |
# editor μλΈλͺ¨λμ΄ μμΌλ©΄ μ°μ μ¬μ©
|
|
|
44 |
except ImportError:
|
45 |
from moviepy import VideoFileClip, concatenate_videoclips
|
46 |
|
47 |
+
# resize ν¨μ: λ€μν λ°©λ²μΌλ‘ μλ
|
48 |
try:
|
49 |
+
from moviepy.video.fx.resize import resize
|
50 |
except ImportError:
|
51 |
+
try:
|
52 |
+
from moviepy.video.fx.all import resize
|
53 |
+
except ImportError:
|
54 |
+
try:
|
55 |
+
from moviepy.video.fx import resize
|
56 |
+
except ImportError:
|
57 |
+
# resizeκ° μμΌλ©΄ λ체 ν¨μ μμ±
|
58 |
+
def resize(clip, newsize):
|
59 |
+
"""Fallback resize function when moviepy resize is not available"""
|
60 |
+
return clip
|
61 |
|
62 |
from moviepy import (
|
63 |
ImageSequenceClip,
|
|
|
67 |
)
|
68 |
from moviepy.video.compositing.CompositeVideoClip import CompositeVideoClip
|
69 |
from moviepy.video.VideoClip import ColorClip
|
70 |
+
# ββ moviepy import ββββββββββββββββββββββββββββββββββββββββββ
|
|
|
71 |
import time
|
72 |
from concurrent.futures import ThreadPoolExecutor
|
73 |
|
|
|
717 |
adjusted_clips = []
|
718 |
for clip, size in zip(video_clips, clip_sizes):
|
719 |
if size != (target_width, target_height):
|
720 |
+
# resize ν¨μκ° μμΌλ©΄ μ¬μ©, μμΌλ©΄ λ체 λ°©λ² μ¬μ©
|
721 |
+
if resize is not None:
|
722 |
+
adjusted_clip = resize(clip, newsize=(target_width, target_height))
|
723 |
+
else:
|
724 |
+
# resizeκ° μμ λ λ체 λ°©λ²
|
725 |
+
# clip.resize() λ©μλ μ¬μ© μλ
|
726 |
+
if hasattr(clip, 'resize'):
|
727 |
+
adjusted_clip = clip.resize((target_width, target_height))
|
728 |
+
else:
|
729 |
+
# μ΅νμ μλ¨: κ·Έλλ‘ μ¬μ©
|
730 |
+
adjusted_clip = clip
|
731 |
+
logging.warning(f"Cannot resize video. Using original size.")
|
732 |
adjusted_clips.append(adjusted_clip)
|
733 |
else:
|
734 |
adjusted_clips.append(clip)
|