LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (http://www.linuxquestions.org/questions/linux-software-2/)
-   -   mp3 conversion using sox automate with cron (http://www.linuxquestions.org/questions/linux-software-2/mp3-conversion-using-sox-automate-with-cron-656533/)

robteks 07-18-2008 12:10 AM

mp3 conversion using sox automate with cron
 
Hi, im trying to convert audio file from .gsm to .mp3 format using sox and lame to be use in asterisk. I created "Makefile" in the audio directory (you can see it below). When i type the command in the CLI it works but when I automate the task using cron it didnt work.

Cron:
* * * * * cd /path/to/my/dir; make mp3


Makefile:
DIRWAV = $(shell dir *.wav)
ALLWAV = $(DIRWAV:.wav=.mp3)
DIRGSM = $(shell dir *.gsm)
ALLGSM = $(DIRGSM:.gsm=.mp3)
mp3: $(ALLGSM) $(ALLWAV)
%.mp3: %.wav
nice lame --quiet -h --preset phone "$?" "$@"
rm -f "$?"
%.wav: %.gsm
nice sox "$?" -r 8000 -c 1 "$@"
rm -f "$?"

robteks 07-18-2008 12:22 AM

I take several test, configuring the cron to send me an email with the result of the 'make mp3' and heres what I got.

nice sox "get.gsm" -r 8000 -c 1 "get.wav"
rm -f "get.gsm"
nice lame --quiet -h --preset phone "get.wav" "get.mp3"
nice: lame: No such file or directory
make: *** [get.mp3] Error 127
rm get.wav


Its not creating .wav file and .mp3 but i know the command is working when i tested it in the cli. Any help and suggestion is appreciated.

Vit77 07-18-2008 04:11 AM

When using crontab, the PATH variable is absent.
So, specify the full path to lame and sox.

To get the full path use which lame

I hope it helps.

robteks 07-18-2008 04:46 AM

Thank you Vit77 for the reply and yes it helps. Actually the PATH variable is not absent it uses the /usr/bin directory, so if i run the lame in the cron it becomes /usr/bin/lame which will not work, I noticed this when the old lame version installed through rpm is executed instead of the latest one which is under /usr/local/bin directory. So i have to change to its real path to work. Thanks.


All times are GMT -5. The time now is 10:07 AM.