I would like to ask you to help me with getting all the frames from video file using Emgu CV. I know I can use Capture
class and its QueryFrame()
method, but this only returns one frame. What is the easiest way to get all the frames? (and save it for example to Image<Bgr, Byte>[]
) I need all the frames to do some more processing (to be more specific: key frame extraction for video summarization).
Thanks a lot for your help.
Even i faced the same issue.So i initialised another timer and provided the video save code in there.And this timer is enabled only when the record button[The button on the form which on click record the video] is clicked.Now i can capture video but the audio is not getting recorded.
See my answer here for reference Emgu Capture plays video super fast
But this should do as you ask I've used a list to store the images you can use an array but you will need to know how big your avi file is.
This was designed to allow playback of the video file at a responsible rate but as your simply converting you could use the Application.Idle method just as easily like this...
You will have to be careful of the end of the file error you will receive an error. You could always use a try catch statement to catch the specific error it will give instead of simply terminating conversion.
If you use to use an image array you will have to loop through the file incrementing a variable and counting the frames and then create the image array before converting the video file to an array.
[EDIT]
As requested this is a method version of retrieving all frames from a video file I have not tested this on a large video file as I expect that the program would crash since it will require a lot of memory.
Alternatively I realise you may wish to record say 10 seconds of video from a webcam so this method will do that, I used a Stopwatch as the the while loop prohibits the use of a timer unless your multi threading the application
and this would be called like this:
Hope this helps,
Cheers,
Chris