codegasmer
codegasmer

Reputation: 1468

Unable to save a recorded file with name as current time

I am using asterisk 11.9.0 and trying to record user voice but unable to save user recording with a name as current time like (2014-06-19 14:40:04.wav) my code

[record]
exten => _X.,1,NoOp(----------Record-----------)
exten => _X.,n,Answer()
exten => _X.,n,set(__START=${CDR(start)})
exten => _X.,n,Playback(hello-world)
exten => _X.,n,Wait(1)
exten => _X.,n,Record(${START}:wav)
exten => _X.,n,Wait(1)
exten => _X.,n,Hangup()

my cli shows

 Executing [4759500@record:5] Record("DAHDI/i1/8826093338-18fe", "2014-06-19 14:40:04:wav") in new stack
    -- <DAHDI/i1/8826093338-18fe> Playing 'beep.gsm' (language 'yes')
[Jun 19 14:40:07] WARNING[19525]: file.c:1181 ast_writefile: No such format '40:04:wav'
[Jun 19 14:40:07] WARNING[19525]: app_record.c:320 record_exec: Could not create file 2014-06-19 14
    -- Executing [4759500@record:6] Wait("DAHDI/i1/8826093338-18fe", "2") in new stack
    -- Executing [4759500@record:7] Hangup("DAHDI/i1/8826093338-18fe", "") in new stack

I think the asterisk search for file format after ":" so the filename with the current time is creating problem.Is there any way to save the current time as recorded file name. Thanks in advance.

Upvotes: 2

Views: 1265

Answers (4)

arheops
arheops

Reputation: 15259

You have use filenames without spaces,otherwise asterisk parse it incorrect.

You have use comma before wav(format) too

Upvotes: -1

js3292
js3292

Reputation: 31

You may do this:

Record(${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)}.wav)

Upvotes: 2

Vicky
Vicky

Reputation: 595

Do not use comma before wav file. If you want to save file with current date time then use this variable ${STRFTIME(${EPOCH},,%d-%m-%Y %H:%M:%S)}.wav

Upvotes: 0

MichelV69
MichelV69

Reputation: 1212

You've got the right idea. You need to replace the ":" in the time with a file-system-friendly character. You can do this one of two ways; one is use a SHELL process with SED to do the work. Or, you can use the REPLACE command from AST.

The following code example is untested. You'll need to read the links included and tweak. I hope this helps you on your way.

[record]
exten => _X.,1,Verbose(2,----------Record-----------)
 same => n,Answer()
 same => n,set(__START=$[REPLACE(:,${CDR(start)}),-])
 same => n,Playback(hello-world)
 same => n,Wait(1)
 same => n,Record(${START}.wav)
 same => n,Wait(1)
 same => n,Hangup()

Note that since Ast 1.2, the ":" to delimit the recording format is replaced with ".".

Recommended Reading:

Upvotes: 0

Related Questions