mathr / blog / #

Encoding PPM/WAV to Ogg Theora/Vorbis

The process:

  1. # input files are PPM/*.ppm and audio.wav, with an empty PNG directory for temporary usage
  2. cd PPM && find -name "*.ppm" -exec convert {} ../PNG/{}.png \; && cd ..
  3. mencoder "mf://PNG/*.png" -mf type=png:fps=25 -ovc raw -o video.avi
  4. avidemux video.avi # add audio.wav as audio track, use COPY/COPY as codecs and save as video2.avi
  5. avifix -F "RGB" -i video2.avi
  6. ffmpeg2theora -V 480 -S 1 -A 128 --optimize video2.avi
  7. # output file is video2.ogg

Some notes:

  • mencoder doesn't support PPM, so convert to PNG
  • avidemux is used simply to multiplex the audio and video into one file
  • avifix is needed to set the fourcc so that ffmpeg2theora can understand
  • ffmpeg2theora doesn't support separate audio / video input streams, so we need to have a single already-multiplexed file to feed it with

There must be a better way to do this.