Spanicin commited on
Commit
7d6f952
1 Parent(s): d480876

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -2
app.py CHANGED
@@ -22,6 +22,7 @@ from flask_cors import CORS, cross_origin
22
  import uuid
23
  import time
24
  from PIL import Image
 
25
 
26
  start_time = time.time()
27
 
@@ -69,6 +70,7 @@ app.config['temp_response'] = None
69
  app.config['generation_thread'] = None
70
  app.config['text_prompt'] = None
71
  app.config['final_video_path'] = None
 
72
 
73
 
74
 
@@ -186,10 +188,15 @@ def main(args):
186
  result, base64_video,temp_file_path = animate_from_coeff.generate(data, save_dir, pic_path, crop_info, \
187
  enhancer=args.enhancer, background_enhancer=args.background_enhancer, preprocess=args.preprocess)
188
 
189
- print('The generated video is named:')
 
 
 
 
190
  app.config['temp_response'] = base64_video
191
  app.config['final_video_path'] = temp_file_path
192
- return base64_video, temp_file_path
 
193
 
194
  # shutil.move(result, save_dir+'.mp4')
195
 
@@ -382,6 +389,7 @@ def check_generation_status():
382
  final_response = app.config['temp_response']
383
  response["base64_video"] = final_response
384
  response["text_prompt"] = app.config.get('text_prompt')
 
385
  response["status"] = "completed"
386
 
387
  final_video_path = app.config['final_video_path']
 
22
  import uuid
23
  import time
24
  from PIL import Image
25
+ import moviepy.editor as mp
26
 
27
  start_time = time.time()
28
 
 
70
  app.config['generation_thread'] = None
71
  app.config['text_prompt'] = None
72
  app.config['final_video_path'] = None
73
+ app.config['final_video_duration'] = None
74
 
75
 
76
 
 
188
  result, base64_video,temp_file_path = animate_from_coeff.generate(data, save_dir, pic_path, crop_info, \
189
  enhancer=args.enhancer, background_enhancer=args.background_enhancer, preprocess=args.preprocess)
190
 
191
+ print('The video is generated')
192
+
193
+ video_clip = mp.VideoFileClip(temp_file_path)
194
+ duration = video_clip.duration
195
+
196
  app.config['temp_response'] = base64_video
197
  app.config['final_video_path'] = temp_file_path
198
+ app.config['final_video_duration'] = duration
199
+ return base64_video, temp_file_path, duration
200
 
201
  # shutil.move(result, save_dir+'.mp4')
202
 
 
389
  final_response = app.config['temp_response']
390
  response["base64_video"] = final_response
391
  response["text_prompt"] = app.config.get('text_prompt')
392
+ response["duration"] = app.config.get('final_video_duration')
393
  response["status"] = "completed"
394
 
395
  final_video_path = app.config['final_video_path']