How to efficiently record & compress AVI animation & GIFs?
18 views (last 30 days)
Show older comments
Saeed Mohammadian
on 17 Jun 2018
Answered: Saeed Mohammadian
on 19 Jun 2018
Hello everyone,
I'm recording a video out of my simulations in a loop and I want a smaller video size WITHOUT changing frame rate. I mean I don't want to decrease the duration of video, which happens when I change the frame rate. Below is my code:
applying the following code to save the video.
% defining file name as:
v = VideoWriter('filename.avi');
v.VideoCompressionMethod
open(v);
and in the loop for t=1:nTstep I apply the following:
%
if (rem(t,5)==0)
A(t) = getframe(gcf);
writeVideo(v,A(t));
This result in a 700 mb size for a 10-second video. Does anyone know how I can decrease it to less than 200 mb or something, without changing the video duration?.
Another thing, I'm eventually converting my avi to GIF and cannot directly do it in conveniently. I've used some codes to generate GIF but my frame rates and other stuff used to change. Can someone introduce a neat way of directly generating GIFs in Matlab?
Thanks a lot
Saeed
1 Comment
Accepted Answer
Walter Roberson
on 17 Jun 2018
For smaller .avi you need to pass a profile as the second argument to VideoWriter; see https://www.mathworks.com/help/matlab/ref/videowriter.html#d119e1242642 . You will probably need to reduce the Quality .
Unfortunately, VideoWriter writes frame by frame, so although it can do backwards references for compression, it never does forward references. A good transcoding program such as vlc can almost always do better.
0 Comments
More Answers (1)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!