fffiloni commited on
Commit
833e264
·
1 Parent(s): de0aaee

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -2
app.py CHANGED
@@ -29,6 +29,13 @@ def get_frame_count_in_duration(filepath):
29
  video.release()
30
  return gr.update(maximum=frame_count)
31
 
 
 
 
 
 
 
 
32
  def resize_video(input_path, output_path, width):
33
  # Load the video clip
34
  video = VideoFileClip(input_path)
@@ -52,6 +59,9 @@ def run_inference(prompt, video_path, condition, video_length):
52
 
53
  # Call the function to resize the video
54
  video_path = resize_video(input_vid, resized_vid, width=512)
 
 
 
55
 
56
  output_path = 'output/'
57
  os.makedirs(output_path, exist_ok=True)
@@ -65,9 +75,9 @@ def run_inference(prompt, video_path, condition, video_length):
65
  os.remove(video_path_output)
66
 
67
  if video_length > 12:
68
- command = f"python inference.py --prompt '{prompt}' --condition '{condition}' --video_path '{video_path}' --output_path '{output_path}' --video_length {video_length} --is_long_video"
69
  else:
70
- command = f"python inference.py --prompt '{prompt}' --condition '{condition}' --video_path '{video_path}' --output_path '{output_path}' --video_length {video_length}"
71
  subprocess.run(command, shell=True)
72
 
73
  # Construct the video path
 
29
  video.release()
30
  return gr.update(maximum=frame_count)
31
 
32
+ def get_video_dimension(filepath):
33
+ video = cv2.VideoCapture(filepath)
34
+ width = int(video.get(cv2.CAP_PROP_FRAME_WIDTH))
35
+ height = int(video.get(cv2.CAP_PROP_FRAME_HEIGHT))
36
+ video.release()
37
+ return width, height
38
+
39
  def resize_video(input_path, output_path, width):
40
  # Load the video clip
41
  video = VideoFileClip(input_path)
 
59
 
60
  # Call the function to resize the video
61
  video_path = resize_video(input_vid, resized_vid, width=512)
62
+ width, height = get_video_dimension(video_path)
63
+
64
+ print(f"{width} x {height}")
65
 
66
  output_path = 'output/'
67
  os.makedirs(output_path, exist_ok=True)
 
75
  os.remove(video_path_output)
76
 
77
  if video_length > 12:
78
+ command = f"python inference.py --prompt '{prompt}' --condition '{condition}' --video_path '{video_path}' --output_path '{output_path}' --width {width} --height {height} --video_length {video_length} --is_long_video"
79
  else:
80
+ command = f"python inference.py --prompt '{prompt}' --condition '{condition}' --video_path '{video_path}' --output_path '{output_path}' --width {width} --height {height} --video_length {video_length}"
81
  subprocess.run(command, shell=True)
82
 
83
  # Construct the video path