sampleIndices method
Upstream sample_frames: rounded linspace over the whole clip.
Implementation
List<int> sampleIndices(int totalFrames, double sourceFps) {
if (totalFrames <= 0 || !sourceFps.isFinite || sourceFps <= 0) {
throw ArgumentError('video needs frames and a positive frame rate');
}
final count = math.min(
math.max((totalFrames / sourceFps * fps).floor(), minFrames),
math.min(maxFrames, totalFrames),
);
if (count == 1) return [0];
// numpy.linspace multiplies a precomputed step and pins the endpoint.
final step = (totalFrames - 1) / (count - 1);
return [
for (var i = 0; i < count - 1; i++) _roundEven(i * step),
totalFrames - 1,
];
}