I am trying to work with large numbers of frames from a video (30000+). I see there are a number of answers out there, but I find none of them satisfying - see below for details.
I understand from painful experience that loading all frames from a video into memory via import
is a bad idea. Instead I am trying to first export all individual frames of the video via an import/crop/export for-loop and will work on individual frames.
I find that import times of individual frames behave very different depending on what frames I want to import:
Table[{x, AbsoluteTiming[Import[vidName, {"Frames", x}]][[1]]}, {x, 1, 30000, 1000}]
I tried using the ffmpeg plugin as suggested here, but can not get it to run.
Likewise the pattern of how import times scale with number of simultaneously imported frames does take on an exponential shape rather than what Karolis observed:
LoadNFrames[n_] := (Import[vid, {"Frames", Range[1, 1 + n]}]; n);
times = Table[AbsoluteTiming[LoadNFrames[n]], {n, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 50,
75, 100, 150}}]
My question hence is: With importing behaving erratic like this, what is the single best way to extract images from videos to work on them? Do I really have to export frames in badges of 3 in a loop?
Thanks,
mondo
EDIT: ran my suggested single-frame import/crop/export loop and found some interesting pattern in the timing for each import:
Does this immediately make sense for anyone?
EDIT 2: I used the same method on another video. This time i get shuffled frame numbers - i.e., my exported frame number 5 fits after frame number 6, and before frame number 7 etc.
Any thoughts, anyone?