Filter löschen
Filter löschen

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

2 Ansichten (letzte 30 Tage)
How do I read a video input irrespective of its file format in a variable?
  2 Kommentare
Sneha_SP
Sneha_SP am 28 Jan. 2011
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 am 28 Jan. 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?

Melden Sie sich an, um zu kommentieren.

Antworten (2)

Matthew Simoneau
Matthew Simoneau am 27 Jan. 2011
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 Kommentare
Sneha_SP
Sneha_SP am 28 Jan. 2011
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 am 28 Jan. 2011
mov(k).cdata is an individual image that has been read in.

Melden Sie sich an, um zu kommentieren.


Walter Roberson
Walter Roberson am 28 Jan. 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.

Kategorien

Mehr zu Convert Image Type finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by