Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -29,10 +29,29 @@ def get_frame_count_in_duration(filepath):
|
|
| 29 |
video.release()
|
| 30 |
return gr.update(maximum=frame_count)
|
| 31 |
|
|
|
|
|
|
|
|
|
|
| 32 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
def run_inference(prompt, video_path, condition, video_length):
|
| 35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
output_path = 'output/'
|
| 38 |
os.makedirs(output_path, exist_ok=True)
|
|
|
|
| 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)
|
| 35 |
|
| 36 |
+
# Calculate the new height while maintaining the aspect ratio
|
| 37 |
+
height = int(video.size[1] * (width / video.size[0]))
|
| 38 |
+
|
| 39 |
+
# Resize the video
|
| 40 |
+
resized_video = video.resize(width=width, height=height)
|
| 41 |
+
|
| 42 |
+
# Write the resized video to the output path
|
| 43 |
+
resized_video.write_videofile(output_path, codec='libx264')
|
| 44 |
+
|
| 45 |
+
return output_path
|
| 46 |
|
| 47 |
def run_inference(prompt, video_path, condition, video_length):
|
| 48 |
|
| 49 |
+
# Specify the input and output paths
|
| 50 |
+
input_vid = video_path
|
| 51 |
+
resized_vid = 'resized.mp4'
|
| 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)
|