Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -223,18 +223,18 @@ def generate_video(image):
|
|
223 |
video_clip = video_clip.set_audio(audio_clip)
|
224 |
print("audio_done")
|
225 |
|
226 |
-
#
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
#
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
return
|
238 |
|
239 |
# 定义 Gradio 接口
|
240 |
interface = gr.Interface(
|
|
|
223 |
video_clip = video_clip.set_audio(audio_clip)
|
224 |
print("audio_done")
|
225 |
|
226 |
+
# 将视频写入临时文件
|
227 |
+
with tempfile.NamedTemporaryFile(delete=False, suffix=".mp4") as tmpfile:
|
228 |
+
video_clip.write_videofile(tmpfile.name, codec="libx264", audio_codec="aac")
|
229 |
+
video_file_path = tmpfile.name
|
230 |
+
|
231 |
+
# 读取临时文件数据并删除
|
232 |
+
with open(video_file_path, 'rb') as f:
|
233 |
+
video_data = f.read()
|
234 |
+
os.remove(video_file_path)
|
235 |
+
os.remove(tmpfile_path)
|
236 |
+
print("video_done")
|
237 |
+
return video_data
|
238 |
|
239 |
# 定义 Gradio 接口
|
240 |
interface = gr.Interface(
|