1
I'm trying to gather data for a datascience project, and am downloading frames from online videos 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 spaced apart from each other.
I have tried
ffmpeg -i "http://www.somevideo.com" -r 1 -f image2 "image%06d.jpg"
and
ffmpeg -i "http://www.somevideo.com" -vf fps=1 "image%06d.jpg"
and eventually 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 all work, but are slow. I have found a hack where I run the following command multiple times, at different offsets, and it seems to be the fastest (where each ffmpeg command is run in parallel multithreaded)
ffmpeg -ss offset -i "http://www.somevideo.com" -vframes frames_per_fragment -an -start_number start_index "image%06d.jpg"
this about 25% faster than the previous method
Is there a faster way to do this? The issue is that downloading over a network is a bottleneck, so I want to download only the frames I need. I'm looking to download videos/frames in bulk, so any speed improvement would be helpful.
What's the container of the video? – Gyan – 2018-12-14T05:07:26.217
the videos are all mp4 – Luay Gharzeddine – 2018-12-14T13:10:55.327