Wav->mp3 Issue with lame

Ubuntu (just upgraded and applied all the patches) 15.10. Asterisk 11.18
I used to run this line with no trouble at the end of an asterisk call:
exten => s,n,System(/usr/bin/lame -B 16 /var/spool/asterisk/monitor/${CALLFILENAME}.wav /var/spool/asterisk/monitor/${CALLFILENAME}.mp3)
Now, the mp3 file is 0 length/empty.
If i run the same command from a prompt :
/usr/bin/lame -B 16 /var/spool/asterisk/monitor/${CALLFILENAME}.wav /var/spool/asterisk/monitor/${CALLFILENAME}.mp3
(hard-coding the filename in), it works fine, so the lame.exe is working ok, its just running under asterisk it doesn’t like.
Any ideas?

It could be a lot of things.


File system permissions

The account Asterisk is running under vs the account you are running the command as

The caller could even be hanging up before the command is run.

I’d start by verifying the command is being run, Try echoing out the command you plan to run to a log file instead of running it.

Thanks for having a look for me.
I’m sure the command is being run because the mp3 is getting made, it’s just zero length.
I also know the source recording is being made because I can examine the wav file being made by asterisk which is ok.

It’s going to be something that @johnkiniston mentioned, or something similar. It is highly unlikely to be anything related to Asterisk.

System simply forks the process, then executes the command using /bin/sh. You can see relevant bits of the code from ast_safe_system here:

int ast_safe_system(const char *s)
	pid = fork();

	if (pid == 0) {
		execl("/bin/sh", "/bin/sh", "-c", s, (char *) NULL);
	} else if (pid > 0) {
		for (;;) {
			res = waitpid(pid, &status, 0);
			if (res > -1) {
				res = WIFEXITED(status) ? WEXITSTATUS(status) : -1;
			} else if (errno != EINTR)
	} else {
		ast_log(LOG_WARNING, "Fork failed: %s\n", strerror(errno));
		res = -1;

Right. I just tried hard-coding the filename of the previously made wav file and the mp3 was made ok, so its as if the wav file of the current call’s recording is stopping the lame procedure call.
Here’s the relevant bit of the dialplan (its only just stopped working out of the blue after a few years): (

exten => h,n, ExecIF($[${DIALSTATUS} = ANSWER]?Goto(RecordedFileManagement,s,1))
exten => s,1,NoOp(${EXTEN}  <-Recording--->   ${DIALSTATUS})
exten => s,n,System(chmod 777 /var/spool/asterisk/monitor/${CALLFILENAME}.wav)
;This failing:
exten => s,n,System(/usr/bin/lame -B 16 /var/spool/asterisk/monitor/${CALLFILENAME}.wav /var/spool/asterisk/monitor/${CALLFILENAME}.mp3)
;This Does Work:
exten => s,n,System(/usr/bin/lame -B 16 /var/spool/asterisk/monitor/HardCodedPreviousCallsFilename.wav /var/spool/asterisk/monitor/test.mp3)