In the Pure Data old school PDP lovers there are a bunch of ninja roads to walk before you can feel comfortable. One of them is to find yourself a comfortable “∞ 2 pure-data” system. You can really get in the deepness of the codec world or you can do it the lazy way. The lazy way is also hard, but the deep way is harder…

This system will depend mostly of the platform(s) you use and the tools you need to produce your video. In my case I like to render video trough the quick pdp/pidip combo.

I run debian unstable and also ubuntu on my work machines. Adding to that the debian multimedia repository I can get almost everything I need, except for the liblame to make pdp and pidip work.

Codecs

The first (tainted) hint I give you is: If you are going to mess around with videos from the Internet, when you install your system you have to spend sometime getting all kinds of codecs. Sad but true. Even more sad: some codecs are forbidden in some countries: check before use.

Install all the non-free codecs, (the video player’s ones and the codec libraries also, and all codecs you find). You will never, ever have too many codecs if you want to be able to use all kinds of formats you find over the Net. Think about the codecs and codec libraries as if they were the weapons in your inventory, or the skills your machine can learn.

Many codecs come comfortably as video packages:

root@omelas:/home/tatiana# apt-get install libavcodec libxvidcore w32codecs

Others come along with video applications:

root@omelas:/home/tatiana# apt-get install ffmpeg mplayer vlc totem

Wathever. You just try to install more and more, download them and install them, always. Each time you use a system. Codec libraries for sure use space, but we have big harddrives lately. Maybe there are some you are not going to use, but honestly I prefer to do

root@omelas:/home/tatiana# apt-cache search codec

… and install everything, than to keep a list, as video population varies a lot.

Demuxers

Then, we have to download the mplayer codecs also, as the MEncoder is one of the main tools we are going to use in this tutorial. Mencoder is a commandline application that converts from one video to another: a demuxer.

The other demuxer we are going to use is the Transcode demuxer. Thanks to the developers!

Video files

Now for the batch encoding to go smoothly, and also for the VJ task in general, we need the files to be in folders, and the folder we use to contain JUST videos and nothing else. No other files or folders. Just videos. We can transcode different types of videos but we always are going to choose badly our encoding if we mix videos with different qualities.

The less encoding we apply, less information we are going to loose. Translation: each time we encode, the loop will get worse quality. If we can skip decoding steps we skip them. When in front of a group of videos we can try different encodings taking one video as a test, and checking if it works with pure data.

We will use a small shell script to do the encoding to pure data. The basic script goes like this:

#! /bin/bash
for A in `ls`; do mencoder -oac mp3lame -ovc lavc -lavcopts vcodec=mjpeg $A -o $A.avi; done;

This means that the script, when run, will make an ls on the directory and with each one of the files it founds it will do mencoder -oac mp3lame -ovc lavc -lavcopts vcodec=mjpeg filename -o filename.avi. That’s why we need to have the videos on folders with no other content.

Depending on the origin of the videos, we may not be able to decode them directly with mencoder, or maybe we need to resize them to our usual size. For this I recommend to have different variations of the script for different needs. In my /usr/local/bin directory, I have currently this variations:

pd_mencoderRESIZE_320-240  pd_transcode24fps.sh       pd_transcodePARACORTAR
pd_mencoder.sh             pd_transcode50fps.sh       pd_transcode.sh
pd_mencoderVOB             pd_transcodeAVI
pd_transcode12fps.sh       pd_transcodeNORESIZE

For more info on mencoder or transcode, have a look at the man pages.

Here you can have all this scripts on a tarball:

video_encoding_for_pd_shell_scripts.tar.gz download

And for testing the resulting codecs, have a look at the I published before.