Page 1 of 1

Below is a video compression code for MATLAB from the internet. the problem is when i put a video through it, the video

Posted: Fri Jul 01, 2022 5:53 am
by answerhappygod
Below is a video compression code for MATLAB from the internet.the problem is when i put a video through it, the video does not compress but becomes biggerthe file was originally 10.1 mb but the output from the MATLAB code became 37.7mbhow to fix this problem so the video gets compressed and becomes smaller?
(the video is a 10 second clip from a 1080p video)
vid=VideoReader('10secvideo1080p.mov');
no=vid.NumberOfFrames;
for i=1:1:no
frames=read(vid,i);
base=sprintf('Image%d.png',i);
ful=fullfile(pwd,base);
imwrite(frames,ful);
im(i)=image(frames);
end
ImFolder=uigetdir;
pngFile = dir(strcat(ImFolder,'\*.png'));
S = [pngFile(:).datenum];
[~,S] = sort(S);
pngFiles = pngFile(S);
VideoFile=strcat(ImFolder,'\Video');
writeObj = VideoWriter(VideoFile);
fps= 15;
writeObj.FrameRate = fps;
open(writeObj);
for t= 1:length(pngFiles)
Frame=imread(strcat(ImFolder,'\',pngFiles(t).name));
writeVideo(writeObj,im2frame(Frame));
end
close(writeObj);