fffiloni commited on
Commit
3606bb1
·
1 Parent(s): c93a0cb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -5
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
- # Add the chunk to the list
57
- chunks.append(chunk)
 
 
 
58
 
59
  # If the last chunk is smaller than the chunk size
60
- if len(chunks) > 0 and len(chunks[-1]) < chunk_size:
61
  # Adjust the end frame of the last chunk to the total frames
62
- chunks[-1] = video.subclip(chunks[-1].t_start, video.duration)
 
 
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