How to change movie to image per frame

4 ビュー (過去 30 日間)
Mr Smart
Mr Smart 2012 年 11 月 20 日
回答済み: Sk Sahariyaz Zaman 2016 年 4 月 28 日
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

回答 (2 件)

Walter Roberson
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.

Sk Sahariyaz Zaman
Sk Sahariyaz Zaman 2016 年 4 月 28 日
Let me know, it solve your problem or not.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by