how to divide the .wmv (movie) format to multiple images?
이전 댓글 표시
sir, Now i need to know how to make the .wmv movie to the multiple frames of the images. here i use the mmreader function to find the frames but it shows the error the
warning: Unable to determine the number of frames in this file.
1. how to find the number of frames in the .wmv
2. Next how to make the movie to the multiple images
답변 (1개)
Walter Roberson
2012년 12월 17일
0 개 추천
The movie is a variable-time movie. You need to read in the entire movie once before mmreader knows the number of frames in the movie.
You use mmreader to read one frame at a time, and imwrite() the cdata of the frame to a file.
댓글 수: 12
ajith
2012년 12월 17일
Walter Roberson
2012년 12월 17일
imwrite(YourDataMatrix, 'YourFileName.tif');
ajith
2012년 12월 18일
Walter Roberson
2012년 12월 18일
readerobj = mmreader('dec072012132350.wmv');
fidx = 1;
while true
try ME
frame = read(readerobj, fidx);
catch
break;
end
imgname = sprintf('frame%05d.tif', fidx);
imwrite(frame, imgname);
fidx = fidx + 1;
end
ajith
2012년 12월 31일
Walter Roberson
2012년 12월 31일
They are only warnings.
To get rid of the second one, change
try ME
to
try
and change
catch
to
catch ME
ajith
2012년 12월 31일
Walter Roberson
2012년 12월 31일
I am not expecting it to show even that. The imwrite() take place silently. But if you like, before the "fidx = fidx + 1" line, add
fprintf('wrote frame to %s\n', imgname);
Walter Roberson
2012년 12월 31일
Any "ans =" you get from my script should be ignored, as the script makes no calculations that are intended to be output.
For your script try
readerobj = mmreader('dec072012132350.wmv');
frame = read(readerobj,inf);
numframe = readerobj.NumberOfFrames;
numframe
ajith
2012년 12월 31일
Walter Roberson
2012년 12월 31일
Yes, that would do it. You cannot name a .m file with a number -- or rather, if you do, the number will be output instead of running the file.
카테고리
도움말 센터 및 File Exchange에서 Get Started with Computer Vision Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!