Skip to content

Instantly share code, notes, and snippets.

@SqrtRyan
Created November 20, 2025 20:30
Show Gist options
  • Select an option

  • Save SqrtRyan/daf853e960ad9aa0b9221307d9393b78 to your computer and use it in GitHub Desktop.

Select an option

Save SqrtRyan/daf853e960ad9aa0b9221307d9393b78 to your computer and use it in GitHub Desktop.
def film_strip(video, length=None, height=None, width=None, vertical=False):
"""
Create a film strip effect from a video sequence.
Args:
video: List of video frames/images
length: Optional number of frames to use (defaults to all frames)
height: Height to resize frames to (default: 480)
width: Width to resize frames to (default: 720)
Returns:
Image with film strip effect applied
"""
if isinstance(length,list):
video=gather_round(video,length)
length=None
if vertical:
video = rp.rotate_images(video, angle=-90)
output = rp.gather_args_recursive_call(vertical=False)
output = rp.rotate_image(output, 90)
return output
if height is None:height=get_video_height(video)
if width is None:width =get_video_width(video)
arrow = crop_image_zeros(skia_text_to_image("⮕", style="black"))
down_arrow = rotate_image(arrow, 90)
arr = partial(join_with_separator, separator=arrow)
pad = partial(bordered_images_solid_color, color="transparent", height=20)
rnd = partial(with_corner_radii, radius=20, antialias=False)
otl = partial(with_alpha_outlines, outer_radius=20, allow_growth=True, color="gray")
if length is not None:
video = resize_list(video, length)
video = resize_images(video, size=(height, width))
video = rnd(video)
video = otl(video)
video = pad(video)
strip = horizontally_concatenated_images(video)
strip = blend_images("black", strip)
alpha = get_alpha_channel(strip)
film_dots = crop_image_zeros(
skia_text_to_image("• " * 300, style="black on white", font="Arial")
)
film_dots = crop_image(film_dots, height=32, origin="center")
alpha = skia_stamp_image(
alpha, film_dots, sprite_origin="top", canvas_origin="top"
)
alpha = skia_stamp_image(
alpha, film_dots, sprite_origin="bottom", canvas_origin="bottom"
)
strip = with_alpha_channel(strip, alpha)
strip = with_corner_radius(strip, 20)
strip = bordered_image_solid_color(strip, "transparent", thickness=40)
return strip
video='/Users/ryan/Downloads/A_splitvideo_where_202511120422_f21gt.mp4'
video=load_video(video,use_cache=True)
a,b=split_tensor_into_regions(video,1,1,2)
a,b=resize_videos_to_fit(a,b,height=480)
#display_video(a)
a,b=resize_lists(a,b,length=100)
def gather_round(x,i):
i=[int(e*(len(x)-1)) for e in i]
return gather(x,i)
#strip_1 = crop_image_zeros(film_strip(a,10))
strip_2 = crop_image_zeros(film_strip(b,5))
################
strip_2 = crop_image_zeros(film_strip(b[full_range([50,40,30,20,10],min=0,max=50).astype(int)]))
#copy_image_to_clipboard(strip_2)
################
def zoom_images(images):
return crop_images(resize_images(images,size=2),*get_video_dimensions(images),origin='center')
strip_2 = crop_image_zeros(
film_strip(
zoom_images(
b[
full_range(
[50, 40, 30, 20, 10],
min=0,
max=50,
).astype(int)
]
)
)
)
#copy_image_to_clipboard(strip_2)
###############
strip_1 = crop_image_zeros(film_strip(resize_list(a,10)[[1,2,3,4,5]]))
copy_image_to_clipboard(strip_1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment