How to change movie to image per frame
2 views (last 30 days)
Show older comments
Hello , anyone does know I need to change video to image with each frames.And now my problem was: I can`t read in matlab, mpg or wav file.When I read this short movie with mmreader . But Matlab says - warning: Unable to determine the number of frames in this file.I have short movie. Here my .m file from internet:
% Read and play back the movie file
obj=mmreader('shuttle.wmv');
nFrames =obj.numberOfFrames;
vidHeight = obj.Height;
vidWidth = obj.Width;
% Preallocate movie structure.
mov(1:nFrames) = ...
struct('cdata', zeros(vidHeight, vidWidth, 3, 'uint8'),...
'colormap', []);
% Read one frame at a time.
for k = 1 : nFrames
mov(k).cdata = read(obj, k);
end
% Size a figure based on the video's width and height.
hf = figure;
set(hf, 'position', [150 150 vidWidth vidHeight])
% Play back the movie once at the video's frame rate.
movie(hf,mov, 1, obj.FrameRate);
******* And how to make video to image per frame.Thanks
0 Comments
Answers (2)
Walter Roberson
on 20 Nov 2012
Edited: Walter Roberson
on 20 Nov 2012
Movies that were recorded with variable frame rates cannot have their numberOfFrames determined until they have been read through completely.
You can work around by not preallocating and simply reading everything at once:
mov = read(obj);
Side note: because of MATLAB's copy-on-write behavior, pre-allocating the cdata field does not help; the cdata will be completely overwritten in your assignment, not using the pre-allocated memory.
0 Comments
Sk Sahariyaz Zaman
on 28 Apr 2016
checkout below link.. - http://www.mathworks.com/matlabcentral/fileexchange/51014-video-player-with-pause-play
Let me know, it solve your problem or not.
0 Comments
See Also
Categories
Find more on Convert Image Type in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!