Update app.py
Browse files
app.py
CHANGED
@@ -77,10 +77,11 @@ def adjust_aspect_ratio(clip, option):
|
|
77 |
def process_video(video,
|
78 |
start_time_str,
|
79 |
end_time_str,
|
80 |
-
platform_option,
|
81 |
-
frame_rate_factor,
|
82 |
speed_factor,
|
83 |
-
repeat_count
|
|
|
84 |
"""
|
85 |
๋์์์ GIF๋ก ๋ณํํ๋ ํจ์
|
86 |
"""
|
@@ -124,6 +125,11 @@ def process_video(video,
|
|
124 |
add_log(f"[LOG 7] ํ๋ซํผ ๋น์จ ์กฐ์ : {platform_option}")
|
125 |
clip = adjust_aspect_ratio(clip, platform_option)
|
126 |
|
|
|
|
|
|
|
|
|
|
|
127 |
# ์ฌ์์๋ ์กฐ์ : speedx๋ฅผ ์ ์ฉํ๋ฉด clip.duration์ ์ค์ด๋ค์ง๋ง fps๋ ๊ทธ๋๋ก ์ ์ง๋จ.
|
128 |
if abs(speed_factor - 1.0) > 1e-3:
|
129 |
add_log(f"[LOG 8] ์ฌ์์๋ {speed_factor}๋ฐฐ๋ก ์กฐ์ ์ค...")
|
@@ -202,10 +208,16 @@ with gr.Blocks() as demo:
|
|
202 |
choices=["์๋ณธ ์ ์ง", "์ ํ๋ธ (16:9)", "์ผ์ธ /๋ฆด์ค (9:16)", "์ ์ฌ๊ฐํ (1:1)", "์ธ์คํ๊ทธ๋จ (4:5)", "ํด๋์ (4:3)"],
|
203 |
value="์๋ณธ ์ ์ง"
|
204 |
)
|
|
|
|
|
|
|
205 |
# ํ๋ ์ ๋ ์ดํธ, ์ฌ์ ์๋, ๋ฐ๋ณต ํ์ ์กฐ์
|
206 |
-
frame_rate_slider = gr.Slider(label="ํ๋ ์ ๋ ์ดํธ ๋ฐฐ์จ ์กฐ์ (0.1 ~ 1.0)",
|
207 |
-
|
208 |
-
|
|
|
|
|
|
|
209 |
# GIF ์์ฑ ๋ฒํผ ๋ฐ ๊ฒฐ๊ณผ ์ถ๋ ฅ
|
210 |
generate_button = gr.Button("GIF ์์ฑํ๊ธฐ")
|
211 |
gif_preview_output = gr.Image(label="์์ฑ๋ GIF ๋ฏธ๋ฆฌ๋ณด๊ธฐ")
|
@@ -225,14 +237,15 @@ with gr.Blocks() as demo:
|
|
225 |
# GIF ์์ฑ ๋ฒํผ ์ด๋ฒคํธ
|
226 |
generate_button.click(fn=process_video,
|
227 |
inputs=[video_input, start_time, end_time,
|
228 |
-
platform_option, frame_rate_slider, speed_slider, repeat_slider
|
|
|
229 |
outputs=[gif_preview_output, download_output, logs_output])
|
230 |
|
231 |
gr.Markdown(
|
232 |
"### [์ฌ์ฉ ๊ฐ์ด๋]\n"
|
233 |
"1. ๋์์์ ์
๋ก๋ํ์ธ์.\n"
|
234 |
"2. ์์/๋ ์๊ฐ์ ์
๋ ฅํ์ธ์.\n"
|
235 |
-
"3. ํ๋ซํผ๋ณ ๊ถ์ฅ ํด์๋/๋น์จ(์๋ณธ ์ ์ง, ์ ํ๋ธ, ์ผ์ธ /๋ฆด์ค, ์ ์ฌ๊ฐํ, ์ธ์คํ๊ทธ๋จ, ํด๋์)
|
236 |
" ํ๋ ์ ๋ ์ดํธ ๋ฐฐ์จ, ์ฌ์ ์๋, ๋ฐ๋ณต ํ์๋ฅผ ์กฐ์ ํ ํ `GIF ์์ฑํ๊ธฐ` ๋ฒํผ์ ๋๋ฅด๋ฉด GIF๊ฐ ์์ฑ๋ฉ๋๋ค.\n"
|
237 |
" - ๋ฐ๋ณต ํ์: 0์ ์ ํํ๋ฉด ๋ฌดํ๋ฐ๋ณต, 1~10์ ํด๋น ํ์๋งํผ ๋ฐ๋ณต๋ฉ๋๋ค.\n"
|
238 |
"4. ๊ฒฐ๊ณผ ๋ฏธ๋ฆฌ๋ณด๊ธฐ์ ๋ค์ด๋ก๋ ๋งํฌ๋ฅผ ํตํด GIF๋ฅผ ํ์ธํ ์ ์์ต๋๋ค."
|
|
|
77 |
def process_video(video,
|
78 |
start_time_str,
|
79 |
end_time_str,
|
80 |
+
platform_option, # ํ๋ซํผ๋ณ ๋น์จ ์ ํ (Radio)
|
81 |
+
frame_rate_factor, # ํ๋ ์ ๋ ์ดํธ ์ถ์ ๋ฐฐ์จ (1.0์ด๋ฉด ์๋ณธ)
|
82 |
speed_factor,
|
83 |
+
repeat_count,
|
84 |
+
resolution_scale): # ์ถ๋ ฅ ํด์๋ ์ถ์ ๋น์จ (1.0์ด๋ฉด ์๋ณธ)
|
85 |
"""
|
86 |
๋์์์ GIF๋ก ๋ณํํ๋ ํจ์
|
87 |
"""
|
|
|
125 |
add_log(f"[LOG 7] ํ๋ซํผ ๋น์จ ์กฐ์ : {platform_option}")
|
126 |
clip = adjust_aspect_ratio(clip, platform_option)
|
127 |
|
128 |
+
# ์ถ๋ ฅ ํด์๋ ์ถ์ ์ต์
์ ์ฉ
|
129 |
+
if abs(resolution_scale - 1.0) > 1e-3:
|
130 |
+
add_log(f"[LOG 7-1] ์ถ๋ ฅ ํด์๋ ์ถ์: {resolution_scale*100:.0f}%")
|
131 |
+
clip = clip.resize(resolution_scale)
|
132 |
+
|
133 |
# ์ฌ์์๋ ์กฐ์ : speedx๋ฅผ ์ ์ฉํ๋ฉด clip.duration์ ์ค์ด๋ค์ง๋ง fps๋ ๊ทธ๋๋ก ์ ์ง๋จ.
|
134 |
if abs(speed_factor - 1.0) > 1e-3:
|
135 |
add_log(f"[LOG 8] ์ฌ์์๋ {speed_factor}๋ฐฐ๋ก ์กฐ์ ์ค...")
|
|
|
208 |
choices=["์๋ณธ ์ ์ง", "์ ํ๋ธ (16:9)", "์ผ์ธ /๋ฆด์ค (9:16)", "์ ์ฌ๊ฐํ (1:1)", "์ธ์คํ๊ทธ๋จ (4:5)", "ํด๋์ (4:3)"],
|
209 |
value="์๋ณธ ์ ์ง"
|
210 |
)
|
211 |
+
# ์ถ๋ ฅ ํด์๋ ์ถ์ ์ต์
(1.0์ด๋ฉด ์๋ณธ, 0.1 ~ 1.0 ๋ฒ์)
|
212 |
+
resolution_scale_slider = gr.Slider(label="์ถ๋ ฅ ํด์๋ ์ถ์ ๋น์จ (0.1 ~ 1.0)",
|
213 |
+
minimum=0.1, maximum=1.0, step=0.1, value=1.0)
|
214 |
# ํ๋ ์ ๋ ์ดํธ, ์ฌ์ ์๋, ๋ฐ๋ณต ํ์ ์กฐ์
|
215 |
+
frame_rate_slider = gr.Slider(label="ํ๋ ์ ๋ ์ดํธ ๋ฐฐ์จ ์กฐ์ (0.1 ~ 1.0)",
|
216 |
+
minimum=0.1, maximum=1.0, step=0.1, value=1.0)
|
217 |
+
speed_slider = gr.Slider(label="์ฌ์ ์๋ ์กฐ์ (0.5 ~ 5.0)",
|
218 |
+
minimum=0.5, maximum=5.0, step=0.1, value=1.0)
|
219 |
+
repeat_slider = gr.Slider(label="GIF ๋ฐ๋ณต ํ์ (0: ๋ฌดํ๋ฐ๋ณต, 1~10: ๋ฐ๋ณต ํ์)",
|
220 |
+
minimum=0, maximum=10, step=1, value=0)
|
221 |
# GIF ์์ฑ ๋ฒํผ ๋ฐ ๊ฒฐ๊ณผ ์ถ๋ ฅ
|
222 |
generate_button = gr.Button("GIF ์์ฑํ๊ธฐ")
|
223 |
gif_preview_output = gr.Image(label="์์ฑ๋ GIF ๋ฏธ๋ฆฌ๋ณด๊ธฐ")
|
|
|
237 |
# GIF ์์ฑ ๋ฒํผ ์ด๋ฒคํธ
|
238 |
generate_button.click(fn=process_video,
|
239 |
inputs=[video_input, start_time, end_time,
|
240 |
+
platform_option, frame_rate_slider, speed_slider, repeat_slider,
|
241 |
+
resolution_scale_slider],
|
242 |
outputs=[gif_preview_output, download_output, logs_output])
|
243 |
|
244 |
gr.Markdown(
|
245 |
"### [์ฌ์ฉ ๊ฐ์ด๋]\n"
|
246 |
"1. ๋์์์ ์
๋ก๋ํ์ธ์.\n"
|
247 |
"2. ์์/๋ ์๊ฐ์ ์
๋ ฅํ์ธ์.\n"
|
248 |
+
"3. ํ๋ซํผ๋ณ ๊ถ์ฅ ํด์๋/๋น์จ(์๋ณธ ์ ์ง, ์ ํ๋ธ, ์ผ์ธ /๋ฆด์ค, ์ ์ฌ๊ฐํ, ์ธ์คํ๊ทธ๋จ, ํด๋์)๊ณผ ์ถ๋ ฅ ํด์๋ ์ถ์ ๋น์จ์ ์ ํํ๊ณ ,\n"
|
249 |
" ํ๋ ์ ๋ ์ดํธ ๋ฐฐ์จ, ์ฌ์ ์๋, ๋ฐ๋ณต ํ์๋ฅผ ์กฐ์ ํ ํ `GIF ์์ฑํ๊ธฐ` ๋ฒํผ์ ๋๋ฅด๋ฉด GIF๊ฐ ์์ฑ๋ฉ๋๋ค.\n"
|
250 |
" - ๋ฐ๋ณต ํ์: 0์ ์ ํํ๋ฉด ๋ฌดํ๋ฐ๋ณต, 1~10์ ํด๋น ํ์๋งํผ ๋ฐ๋ณต๋ฉ๋๋ค.\n"
|
251 |
"4. ๊ฒฐ๊ณผ ๋ฏธ๋ฆฌ๋ณด๊ธฐ์ ๋ค์ด๋ก๋ ๋งํฌ๋ฅผ ํตํด GIF๋ฅผ ํ์ธํ ์ ์์ต๋๋ค."
|