Withdraw 5 seconds of avi

1 view (last 30 days)
Jose
Jose on 23 Sep 2014
Hi, I have the following program, what it does is read a fichero.avi, and receives handles.fin handles.ini and the start time and end of VideoQ segmetno ue want to extract. That time it multiplciamos by fotrograms by segudo and took the frames to be drawn. When trying to take them all with vidFrames = read (handles.readerobj) command says lack of memory, so the bag one second in one second (30 fotrogramas in this case) and generated many videos ed me 1 second to enter the tiepo entrance ....
The case qeu the program generates, but when played in a row is like coming back a few frames. I'm doing it with a GUI, so I put the "assignin" commands to view variables and will do well ... but the result is not right. the videos are not overlapping.
Has anyone done something similar? Or do you know where I'm screwing up?
Thanks in advance.
if true
% code
Forgetfulness %%selected block frames
% Asked the start and end times
handles.numFrames = get (handles.readerobj, 'NumberOfFrames');
handles.frameRate = fix (get (handles.readerobj, 'FrameRate')); assignin ('base', 'handles_frameRate' handles.frameRate);
= handles.fin-handles.inicio cycles; assignin ('base', 'handles_ciclos' cycles); % Rest = rem (frame_fin-frame_ini) / 30); % If (rest = ~ 0)% If we rest one more cycle. % Cycles cycles = + 1; % end
% Calcuamos the start and end frames handles.frame_ini = floor (handles.inicio * handles.frameRate); handles.frame_fin = floor (handles.fin * handles.frameRate);
assignin ('base', 'handles_frame_ini' handles.frame_ini); assignin ('base', 'handles_frame_fin' handles.frame_fin);
% Generate Figure hf = handles.video; handles.position = get (handles.video, 'Position');
for c = 1: cycles video_save = strcat ('video', num2str (c)); % Open file to save as avi vidObj = VideoWriter (video_save); open (vidObj)
% We loaded the frames into an object
assignin ('base', 'handles_readerobj' handles.readerobj);
lastFrame = read (handles.readerobj, inf);
handles.frameRate = fix (get (handles.readerobj, 'FrameRate'));
assignin ('base', 'handles_frameRate' handles.frameRate);
vidFrames = read (handles.readerobj [handles.frame_ini handles.frame_ini + handles.frameRate-1]); % Select 'frameRate' frames
assignin ('base', 'vidFrames' vidFrames);
% Extract the frames of the object
for i = 1: handles.frameRate% selected the following 30 frames
mov (i) = vidFrames .cdata (:,:,:, i);
mov (i) .colormap = [];
end
assignin ('base', 'mov', mov);
Resize% figure based on the video's width and height
set (hf, 'position', handles.position);
axis off
% Playback eleven movie at the video's frame rate
movie (handles.video, mov, 1, handles.readerobj.FrameRate);
assignin ('base', 'handles_readerobj_FrameRate' handles.readerobj.FrameRate);
handles.frame_ini handles.frame_ini% = + handles.frameRate; % Let the next block
handles.frame_ini = handles.frame_ini + handles.frameRate; % Let the next block
assignin ('base', 'handles_frame_ini' handles.frame_ini);
handles.frame_ini
% Save the video
writeVideo (vidObj, mov);
% Close the file
close (vidObj);
mov clear; % We deleted the previous video
end

Answers (0)

Community Treasure Hunt

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

Start Hunting!