GitHub Repo
Transformers Community Reports Video Frame Sampling Bug That May Return Out-of-Bounds Indices
A reproduction on the October 8 Transformers development build found that a uniform frame-sampling function may return more indices than requested, including a position beyond the available frames. The case can be checked without downloading a model, but its impact on stable releases and individual model processors remains unclear.

The Hugging Face Transformers community reported a video preprocessing issue on October 8: after being given the total number of frames and the desired sample count, get_uniform_frame_indices may return both the wrong number of indices and an out-of-bounds index. The report uses Linux, Python 3.12.3, NumPy 2.5.3, and Transformers 5.19.0.dev0 at main-branch commit cb33194. It provides a minimal reproduction that requires neither model weights nor an actual video. Issue report
In the example, total_num_frames is set to 17 and num_frames to 7, but the function returns eight positions: [0, 2, 4, 7, 9, 12, 14, 17]. For a 17-frame video with zero-based indexing, the valid range is 0 through 16, so the final index, 17, is out of bounds. The example directly shows the sampling result is inconsistent, but does not include an end-to-end test of video decoding or model inference failing. Reproduction code and output
Frame sampling determines which images a video model actually sees. The official documentation provides sampling parameters such as num_frames and fps, and allows callers to retrieve sampling indices, original dimensions, duration, and frame rate with return_metadata=True. In practice, engineers can check index bounds before passing frames to a model and retain sampling metadata to help investigate differences in preprocessing and inference results. Video processor documentation
When interpreting this report, it is important to distinguish the underlying function from model-specific sampling rules. The official documentation explicitly notes that processors may enforce minimum or maximum frame limits, so specifying num_frames does not guarantee that the final tensor will contain exactly that many frames. An increase in the sample count alone does not establish that all models are affected; the more specific anomaly here is that the underlying function returns a position outside the original video's range. Sampling behavior notes
If downstream code uses these positions to index a frame array directly, an out-of-bounds value could cause an access failure. This is an engineering inference from the reproduction, not a deployment incident verified in the report. As of this check, the issue remains open, with no maintainer confirmation or linked fix shown. Next, it will be important to track whether the issue reproduces in a stable release, which processors call this function, and whether any fix includes boundary tests across different video lengths and sample counts. Current issue status