Skip to main content

mod_dptools: record

0. About

Record to a file from the channel's input media stream.

1. Syntax

record <path> [<time_limit_secs>] [<silence_threshold>] [<silence_hits>]

Record is used to record voice messages, such as in a voicemail system.

ParameterDescriptionDefault value
pathRecord to file specified by given path in the format that the file's extension specifies. See 2. File Formats below for specifics.If only filename is given the it will be saved to channel variable sound_prefix, or base_dir when sound_prefix not set.
time_limit_secs(optional) The maximum duration of the recording in seconds.TODO Is there a default?
silence_threshold(optional) The energy level below which is considered silence.TODO What is the default?
siilence_hits(optional) The number of seconds of audio below silence_threshold will be tolerated before the recording stops.3 seconds

2. File Formats

The file extension in <path> determines the recorded file's format.

Use the console command show file to display available formats in fs_cli or type fs_cli -x 'show file' in the terminal of your operating system.

For example,

  • record_session /tmp/test.gsm
    will produce a GSM encoded voice file which is raw data and is not in any container (e.g. wav, ogg, etc.). The sampling rate can not be influenced by the filename.
  • record_session /tmp/test.mp3
    will produce an MP3 file if mod_shout is loaded.

You can use external applications such as sox, lame, ffmpeg etc. to resample or otherwise manipulate the recorded file.

3. How to stop the recordings?

Either by hanging up, or setting the playback_terminators variable.

After recording stops, the record app sets the following read-only channel variables:

  • **[record_ms](/freeswitch/Channel-Variables-Catalog/record_ms_16353885#record_ms)** — duration of most recently recorded file in milliseconds
  • **[record_samples](/freeswitch/Channel-Variables-Catalog/record_samples_39419915#record_samples)** — number of recorded samples
  • **[playback_terminator_used](/freeswitch/Channel-Variables-Catalog/playback_terminator_used_16353270#playback_terminator_used)** — TouchTone digit used to terminate recording

The record app sets no record status. TODO What does this mean?

4. Examples

Record app example

<action application="playback" data="/var/sounds/beep.gsm"/>
<!--default terminator is *. Keyword 'none' disables on-key termination /-->

<!--following line will set # as recording session terminator /-->
<action application="set" data="playback_terminators=#"/>
<action application="record" data="/tmp/data.wav 20 200"/>

6. See also