Skip to content

Commit e3960b4

Browse files
committed
Clamp duration if it exceeds video length
1 parent a5a9629 commit e3960b4

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

poseinterface/clips.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@ def extract_clip(
3838
f"filename: {video_path.name}, fps: {video.fps}, shape: {video.shape}"
3939
)
4040

41+
# Clamp duration if it exceeds the video length
42+
if start_frame + duration > video.shape[0]:
43+
duration = video.shape[0] - start_frame
44+
logging.warning(
45+
"Clip exceeds video length. "
46+
f"Clamping duration to {duration} frames."
47+
)
48+
4149
# Slice clip and save as mp4
4250
clip = video[start_frame : start_frame + duration]
4351
clip_path = (

0 commit comments

Comments
 (0)