video – ffmpeg how to extract X frames every interval And from the URL efficiently

I am trying to collect data for a datacience project, and I am downloading video frames online using ffmpeg. I want to download a subset of the frames in the video, without needing to be precise about which, the only requirement is that they are reasonably separated from each other.

I have tried

ffmpeg -i "http://www.somevideo.com" -r 1 -f image2 "image% 06d.jpg"

Y

ffmpeg -i "http://www.somevideo.com" -vf fps = 1 "image% 06d.jpg"

and finally found the following method

ffmpeg -ss offset1 -i "http://www.somevideo.com" -ss offset2 -i "http://www.somevideo.com" -map 0: v -frames: v 10 -start_number 0 "image% 06d .jpg "-map 1: v -frames: v 10 -start_number 10" image% 06d.jpg "

And everything works, but they are slow. I have found a trick in which I execute the following command several times, in different displacements, and it seems to be the fastest (where each ffmpeg command runs in multiprocess in parallel)

ffmpeg -ss offset -i "http://www.somevideo.com" -vframes frames_per_fragment -an -start_number start_index "image% 06d.jpg"

This is 25% faster than the previous method.

Is there a faster way to do this? The problem is that downloading through a network is a bottleneck, so I want to download only the frames I need. I am trying to download videos / frames in bulk, so any improvement in speed would be useful.