How do I save every nth Frame of a video and save these images to a folder of my choosing
11 views (last 30 days)
Show older comments
Jack Zimmerman
on 11 Mar 2019
Commented: Jack Zimmerman
on 15 Mar 2019
I have a video:
'Abuse001_x264.mp4'
I would like to extract every 10th frame from this video and save these as pictures in a folder called: Abuse_Images
How would I go about this?
Accepted Answer
Bjorn Gustavsson
on 11 Mar 2019
If you follow the steps from the help on VideoReader, it should be perfectly possible to replace the frame-by-frame
reading described there to reading of whatever frames you desire - something like:
readerobj = VideoReader('Abuse001_264.mpg', 'tag', 'myreader1');
frames = [1 7 11 13 17 23 29];
for i1 = 1:numel(frames)
Frame = read(readerobj, frames(i1));
outname = sprintf('Outname-%03d.png',i1)
imwrite(Frame,outname)
end
I haven't tested this, but it should work, maybe you want to do more between extracting the frames and writnig them to file, but this should be a useful first step.
HTH
0 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!