Update app.py
Browse files
app.py
CHANGED
|
@@ -8,7 +8,7 @@ import sys
|
|
| 8 |
def process_video(input_video, segment_duration, enable_mix=False):
|
| 9 |
if not input_video:
|
| 10 |
return "請上傳影片"
|
| 11 |
-
|
| 12 |
# 步驟 1: 切割長影片
|
| 13 |
output_dir = "temp_segments"
|
| 14 |
try:
|
|
@@ -16,11 +16,10 @@ def process_video(input_video, segment_duration, enable_mix=False):
|
|
| 16 |
gr.info(f"切割完成:生成 {len(outputs)} 個短片")
|
| 17 |
except Exception as e:
|
| 18 |
return f"切割錯誤:{str(e)}"
|
| 19 |
-
|
| 20 |
# 步驟 2: 可選混剪(使用 pyToVideo2 的 main.py)
|
| 21 |
if enable_mix:
|
| 22 |
try:
|
| 23 |
-
# 假設 pyToVideo2 的 main.py 支援命令行參數(根據實際代碼調整)
|
| 24 |
cmd = [
|
| 25 |
sys.executable, "main.py",
|
| 26 |
"--input_folder", output_dir,
|
|
@@ -36,13 +35,13 @@ def process_video(input_video, segment_duration, enable_mix=False):
|
|
| 36 |
gr.info("混剪完成")
|
| 37 |
except Exception as e:
|
| 38 |
gr.warning(f"混剪錯誤:{str(e)}")
|
| 39 |
-
|
| 40 |
return outputs
|
| 41 |
|
| 42 |
iface = gr.Interface(
|
| 43 |
fn=process_video,
|
| 44 |
inputs=[
|
| 45 |
-
gr.File(
|
| 46 |
gr.Number(label="每段長度 (秒)", value=60),
|
| 47 |
gr.Checkbox(label="啟用 pyToVideo2 混剪", value=False)
|
| 48 |
],
|
|
|
|
| 8 |
def process_video(input_video, segment_duration, enable_mix=False):
|
| 9 |
if not input_video:
|
| 10 |
return "請上傳影片"
|
| 11 |
+
|
| 12 |
# 步驟 1: 切割長影片
|
| 13 |
output_dir = "temp_segments"
|
| 14 |
try:
|
|
|
|
| 16 |
gr.info(f"切割完成:生成 {len(outputs)} 個短片")
|
| 17 |
except Exception as e:
|
| 18 |
return f"切割錯誤:{str(e)}"
|
| 19 |
+
|
| 20 |
# 步驟 2: 可選混剪(使用 pyToVideo2 的 main.py)
|
| 21 |
if enable_mix:
|
| 22 |
try:
|
|
|
|
| 23 |
cmd = [
|
| 24 |
sys.executable, "main.py",
|
| 25 |
"--input_folder", output_dir,
|
|
|
|
| 35 |
gr.info("混剪完成")
|
| 36 |
except Exception as e:
|
| 37 |
gr.warning(f"混剪錯誤:{str(e)}")
|
| 38 |
+
|
| 39 |
return outputs
|
| 40 |
|
| 41 |
iface = gr.Interface(
|
| 42 |
fn=process_video,
|
| 43 |
inputs=[
|
| 44 |
+
gr.File(label="上傳長影片 (MP4)"), # 修正 dlabel 為 label
|
| 45 |
gr.Number(label="每段長度 (秒)", value=60),
|
| 46 |
gr.Checkbox(label="啟用 pyToVideo2 混剪", value=False)
|
| 47 |
],
|