fredag 19 mars 2010

Making a movie in octave

Short: Save each figure to a file using "print(filename)", and stitch together the movie with "ffmpeg" from the command line.

system("rm -rf plot-output; mkdir plot-output");
figure('visible','off');
x=0:0.01:5;
for n=0:100;
plot(x,sin(2*x-n/10));
axis("equal");
print(sprintf("plot-output/%05d.png",n));
endfor;
system("ffmpeg -sameq -i plot-output/%05d.png -y plot-output/movie.avi");
system("open plot-output/movie.avi");