1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
| file, dir] = uigetfile('*.avi');
pfile = fopen( [ dir file ] , 'r' );
if (pfile == -1)
error('Enable to open %s file ',[ dir file ]);
end
% vid = VideoReader(file);
% sz = [vid.Height vid.Width];
% mov = read(vid, [1 vid.NumberOfFrames]);
%
% %# prepare GUI
% p = get(0,'DefaultFigurePosition');
% hFig = figure('Menubar','none', 'Resize','off', ...
% 'Position',[p(1:2) sz(2) sz(1)]);
%
% %# play movie
% movv = struct('cdata',squeeze(num2cell(mov,[1 2 3])), 'colormap',[]);
% movie(hFig, movv, 1, vid.FrameRate);
xyloObj = VideoReader([dir file]);
nFrames = xyloObj.NumberOfFrames;
vidHeight = xyloObj.Height;
vidWidth = xyloObj.Width;
r=b;
g=c;
if (r==0)
debut=1;
fin = g*16;
debut=floor(debut);
fin=floor(fin);
end
if (r>0)
debut=r*15;
fin = g*16;
debut=floor(debut);
fin=floor(fin);
end
h=debut;
xyloObj.NumberOfFrames,
% Preallocate movie structure.
mov(1:fin) = ...
struct('cdata', zeros(vidHeight, vidWidth, 3, 'uint8'),...
'colormap', []);
% Read one frame at a time.
if ( nFrames<fin)
else
for k = 1: (fin-debut)
h=h+1;
mov(h).cdata = read(xyloObj, h);
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, v);
end |
Partager