fffiloni commited on
Commit
f103a90
·
1 Parent(s): e908561

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -44,15 +44,15 @@ def adjust_to_multiple_of_12(number):
44
  number += adjustment
45
  return number
46
 
47
- def resize_video(input_file, new_width):
48
  # Load the video clip
49
  clip = VideoFileClip(input_file)
50
  print(f"WIDTH TARGET: {new_width}")
51
  # Calculate the aspect ratio
52
- ratio = new_width / clip.size[0]
53
  new_height = int(clip.size[1] * ratio)
54
  new_height_adjusted = adjust_to_multiple_of_12(new_height)
55
- new_width_adjusted = adjust_to_multiple_of_12(new_width)
56
  print(f"OLD H: {new_height} | NEW H: {new_height_adjusted}")
57
  print(f"OLD W: {new_width} | NEW W: {new_width_adjusted}")
58
 
@@ -82,7 +82,7 @@ def run_inference(prompt, video_path, condition, video_length):
82
  input_vid = video_path
83
 
84
  # Call the function to resize the video
85
- resized_video_path = resize_video(input_vid, new_width=512)
86
  print(f"PATH TO RESIZED: {resized_video_path}")
87
  width, height, fps = get_video_dimension(resized_video_path)
88
 
@@ -177,7 +177,7 @@ with gr.Blocks(css=css) as demo:
177
  video_path.change(fn=get_frame_count_in_duration,
178
  inputs=[video_path],
179
  outputs=[video_length]
180
- )
181
  submit_btn.click(fn=run_inference,
182
  inputs=[prompt,
183
  video_path,
 
44
  number += adjustment
45
  return number
46
 
47
+ def resize_video(input_file):
48
  # Load the video clip
49
  clip = VideoFileClip(input_file)
50
  print(f"WIDTH TARGET: {new_width}")
51
  # Calculate the aspect ratio
52
+ ratio = 512 / clip.size[0]
53
  new_height = int(clip.size[1] * ratio)
54
  new_height_adjusted = adjust_to_multiple_of_12(new_height)
55
+ new_width_adjusted = adjust_to_multiple_of_12(512)
56
  print(f"OLD H: {new_height} | NEW H: {new_height_adjusted}")
57
  print(f"OLD W: {new_width} | NEW W: {new_width_adjusted}")
58
 
 
82
  input_vid = video_path
83
 
84
  # Call the function to resize the video
85
+ resized_video_path = resize_video(input_vid)
86
  print(f"PATH TO RESIZED: {resized_video_path}")
87
  width, height, fps = get_video_dimension(resized_video_path)
88
 
 
177
  video_path.change(fn=get_frame_count_in_duration,
178
  inputs=[video_path],
179
  outputs=[video_length]
180
+ ).then(fn=resize_video, inputs=[video_path], outputs=[video_path])
181
  submit_btn.click(fn=run_inference,
182
  inputs=[prompt,
183
  video_path,