HongcanGuo commited on
Commit
885201d
·
verified ·
1 Parent(s): 5962a41

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -12
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
- # 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_clip
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(