Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -41,7 +41,7 @@ def split_video_into_chunks(video_path, chunk_size):
|
|
41 |
# Calculate the number of chunks needed
|
42 |
num_chunks = math.ceil(total_frames / chunk_size)
|
43 |
|
44 |
-
# Create a list to store the chunks
|
45 |
chunks = []
|
46 |
|
47 |
# Split the video into chunks
|
@@ -53,13 +53,18 @@ def split_video_into_chunks(video_path, chunk_size):
|
|
53 |
# Extract the chunk from the video
|
54 |
chunk = video.subclip(start_frame / video.fps, end_frame / video.fps)
|
55 |
|
56 |
-
#
|
57 |
-
|
|
|
|
|
|
|
58 |
|
59 |
# If the last chunk is smaller than the chunk size
|
60 |
-
if len(chunks) > 0 and
|
61 |
# Adjust the end frame of the last chunk to the total frames
|
62 |
-
|
|
|
|
|
63 |
|
64 |
return chunks
|
65 |
|
|
|
41 |
# Calculate the number of chunks needed
|
42 |
num_chunks = math.ceil(total_frames / chunk_size)
|
43 |
|
44 |
+
# Create a list to store the chunks and their frame counts
|
45 |
chunks = []
|
46 |
|
47 |
# Split the video into chunks
|
|
|
53 |
# Extract the chunk from the video
|
54 |
chunk = video.subclip(start_frame / video.fps, end_frame / video.fps)
|
55 |
|
56 |
+
# Calculate the frame count for the chunk
|
57 |
+
frame_count = end_frame - start_frame
|
58 |
+
|
59 |
+
# Add the chunk and its frame count to the list
|
60 |
+
chunks.append((chunk, frame_count))
|
61 |
|
62 |
# If the last chunk is smaller than the chunk size
|
63 |
+
if len(chunks) > 0 and chunks[-1][1] < chunk_size:
|
64 |
# Adjust the end frame of the last chunk to the total frames
|
65 |
+
last_chunk = chunks[-1][0]
|
66 |
+
last_frame_count = chunks[-1][1]
|
67 |
+
chunks[-1] = (video.subclip(last_chunk.t_start, video.duration), last_frame_count)
|
68 |
|
69 |
return chunks
|
70 |
|