| import gradio as gr |
| from split_video import split_video |
|
|
| def process_video(input_video, segment_duration): |
| if not input_video: |
| return "請上傳影片" |
| output_dir = "temp_segments" |
| outputs = split_video(input_video, output_dir, int(segment_duration)) |
| return outputs |
|
|
| iface = gr.Interface( |
| fn=process_video, |
| inputs=[ |
| gr.File(label="上傳長影片 (MP4)"), |
| gr.Number(label="每段長度 (秒)", value=60) |
| ], |
| outputs=gr.Files(label="下載短影片"), |
| title="影片切割器 (基於 pyToVideo2)", |
| description="上傳長影片,切割成多段短片。" |
| ) |
|
|
| if __name__ == "__main__": |
| iface.launch() |