How can I export a MATLAB movie in a format that can be played by users on a website in MATLAB 7.6 (R2008a)?
118 views (last 30 days)
Show older comments
MathWorks Support Team
on 27 Jun 2009
Edited: MathWorks Support Team
on 26 Apr 2023
I have created a movie in MATLAB by iteratively calling GETFRAME. I can view the movie using the MOVIE function. I would like to be able to publish my movie on a website. How can I do this? Below is the code I use to generate the movie.
Z = peaks; surf(Z);
% Record the movie with 20 frames
for j = 1:20
% Plot SURF
surf(sin(2*pi*j/20)*Z,Z)
% Get the frame
F(j) = getframe;
end
%Play the movie
movie(F)
Accepted Answer
MathWorks Support Team
on 27 Jun 2009
The best way to export a movie from MATLAB is to use the command MOVIE2AVI. For example, after executing the code above, the following command can be issued:
movie2avi(F,'myavifile.avi','Compression','Cinepak')
The following html code can then be used to allow the movie to be viewed on a web page:
<embed align="center" src="myavifile.avi" width="640" height="480" autoplay="true" controller="true" cache="true" type="video/x-msvideo" </embed>
Or a link can be created so that the user can download the AVI file:
<a href="myavifile.avi">Here is a movie to download</a>
Note that for this example to work, the HTML file and the generated AVI file must be in the same directory.
3 Comments
Walter Roberson
on 19 Oct 2020
The question very specifically asks about
MATLAB 7.6 (R2008a)
So what is required in current MATLAB versions is only relevant as a side note.
More Answers (0)
See Also
Categories
Find more on MATLAB Report Generator in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!