KingNish commited on
Commit
97c9888
1 Parent(s): f489c9c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -8
app.py CHANGED
@@ -72,14 +72,11 @@ def fn(vid, bg_type="Color", bg_image=None, bg_video=None, color="#00FF00", fps=
72
  bg_frame_index += 1
73
  background_image = Image.fromarray(background_frame)
74
  processed_image = process(pil_image, background_image)
75
- else: # video_handling == "loop"
76
- try:
77
- background_frame = next(background_frames)
78
- background_image = Image.fromarray(background_frame)
79
- processed_image = process(pil_image, background_image)
80
- except StopIteration:
81
- # Handle case where background video is shorter than input video
82
- processed_image = process(pil_image, "#000000") # Default to black background
83
  else:
84
  processed_image = pil_image # Default to original image if no background is selected
85
 
 
72
  bg_frame_index += 1
73
  background_image = Image.fromarray(background_frame)
74
  processed_image = process(pil_image, background_image)
75
+ else: # video_handling == "loop"
76
+ background_frame = background_frames[bg_frame_index % len(background_frames)]
77
+ bg_frame_index += 1
78
+ background_image = Image.fromarray(background_frame)
79
+ processed_image = process(pil_image, background_image)
 
 
 
80
  else:
81
  processed_image = pil_image # Default to original image if no background is selected
82