Make a movie from series of Fig file

Hello everyone
I have a series of .fig file as shown like this.
How I can create the video by MATLAB.
Thanks in advance

Answers (2)

video = VideoWriter('Movie.avi');
open(video);
folder = 'D\Folder';
str = int2str(i);
for i=1:N
Image = strcat(folder,'\',int2str(i),'.fig');
I = imread(Image);
writeVideo(video,I);
end
close(video);

10 Comments

Hello, Sudhakar Shinde
Thanks you for your replied, however when i run the code its apprear
"Error using VideoWriter (line 167)
A file name must be specified."
How to fixed this ?
Thanks in advance.
can you try on command window and check if error observed or this is successful :
video = VideoWriter('Movie.avi')
When i try only this command
video = VideoWriter('Movie.avi')
It is successful
video =
VideoWriter
General Properties:
Filename: 'Movie.avi'
Path: 'E:\Thesis_PhD\Code_optimization\BESO_3D_MATLAB\Beam-SHS Column (Original)'
FileFormat: 'avi'
Duration: 0
Video Properties:
ColorChannels: 3
Height: []
Width: []
FrameCount: 0
FrameRate: 30
VideoBitsPerPixel: 24
VideoFormat: 'RGB24'
VideoCompressionMethod: 'Motion JPEG'
Quality: 75
Methods
ok so where is the error ? Is this error during execution of writeVideo(video,I); ?
I got an error when i manually run on this following line
Image = strcat(folder,'\',int2str(i),'.fig');
I = imread(Image);
writeVideo(video,I);
At imread command it was error and shown as
Error using imread>get_format_info (line 491)
Unable to determine the file format.
Error in imread (line 354)
fmt_s = get_format_info(fullname);
Have you added path of your image folders in 'folder' variable
video = VideoWriter('Movie.avi');
open(video);
folder = 'E:\Thesis_PhD\Code_optimization\BESO_3D_MATLAB\Beam-SHS Column (Original)';
str = int2str(i);
for i=1:48
Image = strcat(folder,'\',int2str(i),'.fig');
I = imread(Image);
writeVideo(video,I);
end
close(video);
This is my implementation of the code
Can you attach fig file example here
But my .fig file are larger than 5 mbs.
Is there any possible way to attach the files ?
fig file is not supported for imread. So it could not works. Check supported formats for imread by using command - 'imformats'.
One thought if there will not be any data loss , you can convert .fig to supported format and use above solution. But look for any kind of data loss during conversion.

Sign in to comment.

It's best not to save your screenshots out as .fig files. You should save them as PNG instead. Or just create the video directly from the axes on the figure as you change it. See attached demos.

Asked:

on 15 Oct 2020

Answered:

on 15 Oct 2020

Community Treasure Hunt

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

Start Hunting!