width = 750
height = 250
nframes = 360
fps = 30
samplerate = 22050L
video = IDLffVideoWrite('animation.mp4')
videoStream = video.addVideoStream(width, height, fps)
audioStream = video.addAudioStream(samplerate)
hello = fix(100 * read_wav(file_which('hello.wav')))
hello_size = n_elements(hello)
nhellos = samplerate * nframes / fps / hello_size
hello = reform(rebin(reform(hello, hello_size, 1), hello_size, nhellos), nhellos * hello_size)
time = video->put(audioStream, hello)
nperiods = 4
x = findgen(nperiods * 360) * !dtor
p = plot(x, sin(x) / (x + 1 * !dtor), $
xrange=[0., nperiods * 2. * !pi], yrange=[-2., 2.], $
dimensions=[width, height], $
axis_style=1, color='red', thick=2, $
xtickfont_size=8, ytickfont_size=8)
for i = 0L, nframes - 1L do begin
p->setData, x, sin(x - i * 5 * !dtor) / (x + 1 * !dtor)
time = video->put(videoStream, p->copyWindow())
endfor
video->cleanup
end