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

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

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

Post 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);
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply