Calling apps from php

Guys this is really frying my head (being a Linux noob since Monday!)

OK I have installed ffmepg, mplayer + mencoder, flvtool2 and lame ‘successfully’.

Now my problems come in using them.

On initial connection to through shell clinet to th command line if I execute the command my php script would call:

/home/USER/bin/mencoder /home/USERNAME/ -o /home/USERNAME/ -of lavf -oac mp3lame -lameopts abr:br=56 -ovc lavc -lavcopts vcodec=flv:vbitrate=800:mbd=2:mv0:trell:v4mv:cbp:last_pred=3 -vf scale=390:290 -srate 22050

I get this response:

/home/USER/bin/mencoder: error while loading shared libraries: cannot open shared object file: No such file or directory

now if I execute these commands (probably don’t need all of them but got it from a tutoril for install):

export TMPDIR=$HOME/tmp
export PATH=$HOME/bin:$PATH
export LD_LIBRARY_PATH=$HOME/lib:/usr/local/lib:$LD_LIBRARY_PATH
export CPATH=$HOME/include:/usr/local/include:$CPATH
export LIBRARY_PATH=$HOME/lib:/usr/local/lib:$LIBRARY_PATH

and execute the mencoder stuff agin it works fine…

now obviously I need to call this from php so need someway of making sure evereything is available.

Is there anything I can do in the unix environment to make sure these paths are available permanently or is there something I can do in php to mimc the export commands in my (exec) statement.

Like i said - bit of a noob so if anyone would be so kind and provide a kind of step by step walkthrough I would be VERY appreciative.

Thanks guys (n gals) if anyone can help I may be able to offer some free icecream (sent by post! ;P)