global frames;
global fila;
obj=mmreader(fila);
a=read(obj);
frames=get(obj,'numberOfFrames');
for k = 1 : 50
v1(k).cdata = a(:,:,:,k);
v1(k).colormap = [];
end
frames = {v1.cdata};
str2='.png';
for i=1:length(frames)
filename1=strcat(num2str(i),str2 ); imwrite(frames{i},filename1); data1 = imread(filename1); data2 = imresize(data1,[144 176]); iFile = filename1; imwrite(data2,iFile,'png');
end
frames = {v1.cdata};
??? Error using ==> png
Could not open file.
Error in ==> writepng at 429
png('write', data, map, filename, colortype, bitdepth, …
Error in ==> imwrite at 477
feval(fmt_s.write, data, map,
filename, paramPairs{:});
Error in ==> main>pushbutton2_Callback at 204
imwrite(data2,iFile,'png');
Sometimes the loop completes giving all the frames of the video of required resolution without any error but sometimes it generates a random number of images and then gives this error. For a few videos i tried, the loop pops up this error even before generating any image at all.
This loop works even without mentioning the 'png' parameter in both imwrite but the result is the same error.
Default toolboxes and block sets present.
Best Answer