How do I read a video file of arbitrary format and store its frames in a variable?
Mostrar comentarios más antiguos
How do I read a video input irrespective of its file format in a variable?
2 comentarios
Sneha_SP
el 28 de En. de 2011
Todd Flanagan
el 28 de En. de 2011
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?
Respuestas (2)
Matthew Simoneau
el 27 de En. de 2011
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 comentarios
Sneha_SP
el 28 de En. de 2011
Walter Roberson
el 28 de En. de 2011
mov(k).cdata is an individual image that has been read in.
Walter Roberson
el 28 de En. de 2011
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.
Categorías
Más información sobre Convert Image Type en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!