# mathr / blog / #

## Encoding to AVI from multiple JPEG images and WAV audio

Last night I built a Pd+Gridflow patch that makes sound from visual feedback. I played around with it for a while, and recorded some of the audio output, but I really wanted to record the images too, and the interestingness of the interrelation of the images and the sounds. Not in the mood to fiddle around, I set about making my patch save all 2 frames per second to a sequence of .jpg files, and the audio as a separate .wav file.

After 40 minutes of recording I had a mass of image files and a big audio file, so now I set about finding out how to make a video file from them - XVID+MP3 AVI would do nicely. Some googling later and I came up with this script:

export XVIDOPTS="me_quality=6:chroma_me:chroma_opt:trellis:max_key_interval=300:vhq=4"
mencoder -nosound -ovc xvid -xvidencopts turbo:stats:$XVIDOPTS:pass=1 -o /dev/null mf://\*.jpg mencoder -nosound -ovc xvid -xvidencopts$XVIDOPTS:pass=2:bitrate=800 -mf type=jpg:fps=2 -o output.avi mf://\*.jpg

which encoded the images into a .avi without sound. Then I combined with the .wav using avidemux2, which did the encoding of the audio to 192kbps cbr mp3 to get the final .avi.

EDIT 2020 the original AVI seems lost in time, but the 84MB MPEG is online.

a sudden rain shower

motherboard 4 fan