When feeding videos into a model, a common first step is to sample a fixed number of frames from a clip and normalize their pixel values. Uniform temporal sampling picks frames at evenly spaced positions along the time axis so the chosen frames span the whole clip, regardless of its original length.
Implement sample_and_preprocess(video, num_frames) that:
(T, H, W, C) with integer pixel values in [0, 255].num_frames frame indices that are evenly spaced across the time dimension, including the first and last frame when num_frames > 1.[0.0, 1.0] by dividing by 255.(num_frames, H, W, C).video: array-like of shape (T, H, W, C), T >= 1.num_frames: positive integer, num_frames <= T.num_frames == 1, sample the first frame (index 0).num_frames > T, which is outside the allowed range.