How to change movie to image per frame
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(2 个)
Walter Roberson
2012-11-20
编辑:Walter Roberson
2012-11-20
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 个评论
Sk Sahariyaz Zaman
2016-4-28
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Convert Image Type 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!