Spanicin commited on
Commit
a82704b
·
verified ·
1 Parent(s): 3ad1e43

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -6
app.py CHANGED
@@ -213,21 +213,33 @@ def main(args):
213
  without_rl1=False
214
  )
215
 
216
- print('The video is generated')
217
-
218
- with open(output_path, 'rb') as f:
 
 
 
 
 
 
 
 
 
 
 
 
219
  video_content = f.read()
220
 
221
  base64_lipsync_video = base64.b64encode(video_content).decode('utf-8')
222
 
223
- video_clip = mp.VideoFileClip(output_path)
224
  duration = video_clip.duration
225
 
226
  app.config['temp_response'] = base64_lipsync_video
227
- app.config['final_video_path'] = output_path
228
  app.config['final_video_duration'] = duration
229
 
230
- return base64_lipsync_video, output_path, duration
231
 
232
  # shutil.move(result, save_dir+'.mp4')
233
 
 
213
  without_rl1=False
214
  )
215
 
216
+ print('The video with lip sync is generated')
217
+ print("GFPGAN Activated")
218
+
219
+ process_video_with_gfpgan(output_path, output_path)
220
+ audio_clip = AudioFileClip(new_audio_path)
221
+ video_clip = VideoFileClip(output_path)
222
+ # Combine audio and video
223
+ final_clip = video_clip.set_audio(audio_clip)
224
+
225
+ temp_file = tempfile.NamedTemporaryFile(suffix='.mp4', delete=False)
226
+ temp_file.close()
227
+ final_video_path = temp_file.name
228
+ final_clip.write_videofile(final_video_path)
229
+
230
+ with open(final_video_path, 'rb') as f:
231
  video_content = f.read()
232
 
233
  base64_lipsync_video = base64.b64encode(video_content).decode('utf-8')
234
 
235
+ video_clip = mp.VideoFileClip(final_video_path)
236
  duration = video_clip.duration
237
 
238
  app.config['temp_response'] = base64_lipsync_video
239
+ app.config['final_video_path'] = final_video_path
240
  app.config['final_video_duration'] = duration
241
 
242
+ return base64_lipsync_video, final_video_path, duration
243
 
244
  # shutil.move(result, save_dir+'.mp4')
245