fffiloni commited on
Commit
dd0e95b
1 Parent(s): 7f3f496

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -14
app.py CHANGED
@@ -137,31 +137,33 @@ def run_inference(prompt, video_path, condition, video_length, seed, steps):
137
  # Calculate the new height while maintaining the aspect ratio
138
  n_height = int(o_height / o_width * 512)
139
  n_width = 512
140
-
141
- # Get FPS of original video input
142
- target_fps = get_video_dimension(video_path)[2]
143
- if target_fps > 12 :
144
- print(f"FPS is too high: {target_fps}")
145
- video_length = int((12 * video_length) / target_fps)
146
-
147
- target_fps = 12
148
- print(f"NEW INPUT FPS: {target_fps}, NEW FPS: {video_length}")
149
-
150
- # Count total frames according to fps
151
- total_frames = get_video_dimension(video_path)[3]
152
 
153
- # Resize the video
154
  r_width = make_nearest_multiple_of_32(n_width)
155
  r_height = make_nearest_multiple_of_32(n_height)
156
  print(f"multiple of 32 sizes : {r_width}x{r_height}")
157
- # Check if the file already exists
 
 
 
 
 
 
 
 
158
  if os.path.exists('resized.mp4'):
159
  # Delete the existing file
160
  os.remove('resized.mp4')
 
161
  resized = resize_video(video_path, 'resized.mp4', r_width, r_height, target_fps)
162
  resized_video_fcount = get_video_dimension(resized)[3]
163
  print(f"RESIZED VIDEO FRAME COUNT: {resized_video_fcount}")
164
 
 
 
 
 
 
165
  # normalize pixels
166
  #normalized = normalize_and_save_video(resized, 'normalized.mp4')
167
 
 
137
  # Calculate the new height while maintaining the aspect ratio
138
  n_height = int(o_height / o_width * 512)
139
  n_width = 512
 
 
 
 
 
 
 
 
 
 
 
 
140
 
141
+ # Make sure new dimensions are multipe of 32
142
  r_width = make_nearest_multiple_of_32(n_width)
143
  r_height = make_nearest_multiple_of_32(n_height)
144
  print(f"multiple of 32 sizes : {r_width}x{r_height}")
145
+
146
+ # Get FPS of original video input
147
+ original_fps = get_video_dimension(video_path)[2]
148
+ if target_fps > 12 :
149
+ print(f"FPS is too high: {original_fps}")
150
+ target_fps = 12
151
+ print(f"NEW INPUT FPS: {target_fps}, NEW LENGTH: {video_length}")
152
+
153
+ # Check if the resized file already exists
154
  if os.path.exists('resized.mp4'):
155
  # Delete the existing file
156
  os.remove('resized.mp4')
157
+
158
  resized = resize_video(video_path, 'resized.mp4', r_width, r_height, target_fps)
159
  resized_video_fcount = get_video_dimension(resized)[3]
160
  print(f"RESIZED VIDEO FRAME COUNT: {resized_video_fcount}")
161
 
162
+ # Make sure new total frame count is enough to handle chosen video length
163
+ # if video_length > resized_video_fcount :
164
+ # video_length = int((target_fps * video_length) / original_fps)
165
+
166
+
167
  # normalize pixels
168
  #normalized = normalize_and_save_video(resized, 'normalized.mp4')
169