fffiloni commited on
Commit
d3c88cc
1 Parent(s): cb7d2da

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -43
app.py CHANGED
@@ -79,45 +79,6 @@ def resize_video(input_vid, output_vid, width, height, fps):
79
  print(f"RESIZE VIDEO DONE!")
80
  return output_vid
81
 
82
- def normalize_and_save_video(input_video_path, output_video_path):
83
- print(f"NORMALIZING ...")
84
- cap = cv2.VideoCapture(input_video_path)
85
-
86
- # Get video properties
87
- frame_count = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))
88
- width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
89
- height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
90
- fps = cap.get(cv2.CAP_PROP_FPS)
91
-
92
- # Create VideoWriter object to save the normalized video
93
- fourcc = cv2.VideoWriter_fourcc(*'mp4v') # Specify the codec (e.g., 'mp4v', 'XVID', 'MPEG')
94
- out = cv2.VideoWriter(output_video_path, fourcc, fps, (width, height))
95
-
96
- # Iterate through each frame in the video
97
- for _ in range(frame_count):
98
- ret, frame = cap.read()
99
- if not ret:
100
- break
101
-
102
- # Convert frame to floating point
103
- frame = frame.astype(np.float32)
104
-
105
- # Normalize pixel values to the range [0, 1]
106
- frame /= 255.0
107
-
108
- # Convert normalized frame back to 8-bit unsigned integer
109
- frame = (frame * 255.0).astype(np.uint8)
110
-
111
- # Write the normalized frame to the output video file
112
- out.write(frame)
113
-
114
- # Release the VideoCapture and VideoWriter objects
115
- cap.release()
116
- out.release()
117
-
118
- print(f"NORMALIZE DONE!")
119
- return output_video_path
120
-
121
  def make_nearest_multiple_of_32(number):
122
  remainder = number % 32
123
  if remainder <= 16:
@@ -163,10 +124,6 @@ def run_inference(prompt, video_path, condition, video_length, seed, steps):
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
-
170
  output_path = 'output/'
171
  os.makedirs(output_path, exist_ok=True)
172
 
@@ -196,6 +153,9 @@ def run_inference(prompt, video_path, condition, video_length, seed, steps):
196
  #o_height = get_video_dimension(video_path)[1]
197
  #resize_video(video_path_output, 'resized_final.mp4', o_width, o_height, target_fps)
198
 
 
 
 
199
  print(f"FINISHED !")
200
  return "done", video_path_output
201
 
 
79
  print(f"RESIZE VIDEO DONE!")
80
  return output_vid
81
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
82
  def make_nearest_multiple_of_32(number):
83
  remainder = number % 32
84
  if remainder <= 16:
 
124
  # if video_length > resized_video_fcount :
125
  # video_length = int((target_fps * video_length) / original_fps)
126
 
 
 
 
 
127
  output_path = 'output/'
128
  os.makedirs(output_path, exist_ok=True)
129
 
 
153
  #o_height = get_video_dimension(video_path)[1]
154
  #resize_video(video_path_output, 'resized_final.mp4', o_width, o_height, target_fps)
155
 
156
+ # Check generated video FPS
157
+ gen_fps = get_video_dimension(video_path_output)[2]
158
+ print(f"GEN VIDEO FPS: {gen_fps}")
159
  print(f"FINISHED !")
160
  return "done", video_path_output
161