How do I read a video file of arbitrary format and store its frames in a variable?

조회 수: 1 (최근 30일)
How do I read a video input irrespective of its file format in a variable?
  댓글 수: 2
Sneha_SP
Sneha_SP 2011년 1월 28일
i want to convert a video in to an image sequence & the program should be able to convert any video irrespective of its format...
Todd Flanagan
Todd Flanagan 2011년 1월 28일
I think that it would be helpful if you added a little more detail about what you are trying to accomplish. For example, are there some common video formats that you expect? Are you having difficulty reading a particular format?

댓글을 달려면 로그인하십시오.

답변 (2개)

Matthew Simoneau
Matthew Simoneau 2011년 1월 27일
See Reading Video Files with Video Reader.
Here is an example from that page:
xyloObj = VideoReader('xylophone.mpg');
nFrames = xyloObj.NumberOfFrames;
vidHeight = xyloObj.Height;
vidWidth = xyloObj.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(xyloObj, k);
end
% Play back the movie once at the video's frame rate.
movie(mov, 1, xyloObj.FrameRate);
  댓글 수: 2
Sneha_SP
Sneha_SP 2011년 1월 28일
no i want to convert a video in to an image sequence & the program should be able to convert any video irrespective of its format...
Walter Roberson
Walter Roberson 2011년 1월 28일
mov(k).cdata is an individual image that has been read in.

댓글을 달려면 로그인하십시오.


Walter Roberson
Walter Roberson 2011년 1월 28일
I have included a complete 36 minute video on the line below:
$
That is the entire file contents, the single character '$'.
I have included a completely different 36 minute video on the line below:
$
That is the entire file contents, the single character '$'. But it's a different video than the other one. The first one was a small video that was a constant red for the entire 36 minutes, but this other one is a larger video that fades from yellow to black over the entire 36 minutes.
You look dubious, but it is true. Here, I'll show you:
>> double('$')
ans =
36
Character with value decimal 36, 36 minute movie, deterministic behaviour, fixed size for each program -- is it not clear that such video files could indeed be created and read by some display program?
But we have a conflict. Does $ mean constant red or does it mean fading yellow? Clearly we can write a program for either meaning.
What can we conclude? This: that it is not possible to write a program that can convert "any video irrespective of its format". Every data file represents an infinite number of different videos when interpreted by appropriate programs.
The meaning of any particular data file depends on the program that is to read it. There is no universal catalog of video formats and there never can be.

카테고리

Help CenterFile Exchange에서 Convert Image Type에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by