Implementing Video Recording in Asterisk

Hello everyone,

I’m currently setting up an Asterisk system that needs to handle video calls, and I want to ensure that both audio and video are recorded properly. I’ve already done with audio recording using MixMonitor but i am not able the record the video, can you please tell me how i can record the video?

There is no support for recording video using MixMonitor. The only recording support is via Record(), and even then it is not used often.

Hii @jcolp

Thank you for your response.

I’m trying to record video in Asterisk using the Record() application since I understand that MixMonitor does not support video recording. I’ve set up the following dialplan:

ini

exten => 2001,1,NoOp(Call from ${CALLERID(num)} to 2001 in context)
same => n,Set(CALL_TIMESTAMP=${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)})
same => n,Set(FILENAME=${CALLERID(num)}-${UNIQUEID}-${CALL_TIMESTAMP}.h264)
same => n,Record(/var/spool/asterisk/monitor/${FILENAME},7200,b)
same => n,Dial(PJSIP/2001)
same => n,Hangup()

However, when I attempt to record, I encounter the following errors:

[Aug 23 12:18:41] WARNING[196671][C-00000024]: app_record.c:297 record_exec: 'b' is not a valid maximum duration
[Aug 23 12:18:42] WARNING[196671][C-00000024]: translate.c:495 ast_translator_build_path: No translator path: (ending codec is not valid)
[Aug 23 12:18:42] WARNING[196671][C-00000024]: file.c:281 ast_writestream: Unable to translate to format h264, source format slin
[Aug 23 12:18:42] WARNING[196671][C-00000024]: app_record.c:430 record_exec: Problem writing frame

It seems like the asterisk is having trouble with the H.264 codec and translating between audio and video formats.

I have some question on that

  1. Codec Compatibility: How can I ensure that the Record() application properly handles video (H.264 codec) in Asterisk? Is there a specific configuration or module I need to enable?
  2. Error Handling: What’s the correct way to specify options in Record() for video recording? The b option caused an error; should it be omitted or replaced with something else?
  3. Translator Path Issues: The error suggests there’s a problem with the translator path. How can I troubleshoot and resolve this? Are there known issues with using H.264 for recording in Asterisk?

I’m using Asterisk version 18.23.1, and I’m trying to record both audio and video from a PJSIP call and also is there any other method to record the video!. Any guidance or suggestions would be greatly appreciated!

The format_h264 module is used for writing out the file. The options and arguments to Record are documented[1]. It has no “b” option. It is also NOT equivalent to MixMonitor. If you want to record both audio and video while a call is going on with someone else then that is not supported. You can’t do it. If Record doesn’t work then it’s probably broken, in which case you can’t use it. Recording and playback of video is not something anyone has really spent time on.

[1] Record - Asterisk Documentation

I went through your given documentation and modified the dialplan

exten => 2001,1,NoOp(Call from ${CALLERID(num)} to 2001 in context)
same => n,Set(CALL_TIMESTAMP=${STRFTIME(${EPOCH},%Y%m%d-%H%M%S)})
same => n,Set(FILENAME=${CALLERID(num)}-${UNIQUEID}-${CALL_TIMESTAMP}.h264)
same => n,Record(/var/spool/asterisk/monitor/${FILENAME},0,7200,s)
same => n,Dial(PJSIP/2001)
same => n,Hangup()

but after that i am not getting any error but the file is not saving in the /var/spool/asterisk/monitor directory. Is the video stream is not receiving in that particular channel?

– Executing [2001@genea:1] NoOp(“PJSIP/2004-00000002”, “Call from 2004 to 2001 in context”) in new stack
– Executing [2001@genea:2] Set(“PJSIP/2004-00000002”, “CALL_TIMESTAMP=20240823-200102”) in new stack
– Executing [2001@genea:3] Set(“PJSIP/2004-00000002”, “FILENAME=2004-1724443262.10-20240823-200102.h264”) in new stack
– Executing [2001@genea:4] Record(“PJSIP/2004-00000002”, “/var/spool/asterisk/monitor/2004-1724443262.10-20240823-200102.h264,0,7200,s”) in new stack
– Executing [2001@genea:5] Dial(“PJSIP/2004-00000002”, “PJSIP/2001”) in new stack
– Called PJSIP/2001
– PJSIP/2001-00000003 is ringing

I don’t know, maybe, or it’s not working. I also don’t think it will do as you want in the first place. Asterisk just doesn’t have good support for recording such things. You can keep trying, but you’re just going to keep hitting roadblocks/shortcomings/broken stuff and that’s not going to change.

You seem to be assuming that Record runs in the background, like MixMonitor, but it is a foreground operation. As such, no option setting will make it work the way you want, but I think the reason it is exiting quickly is because you are using the s option on an unanswered call.

The outgoing leg will not be attempted until the recording is complete.

@david551 can you please tell me how we can run it as foreground operation and how we can record the video in asterisk

It only runs as a foreground operation. I believe you actually want a background operation.

You will need to modify the source code, but I don’t think you have the the skills needed to do that. It will not be a quick change.

can you please tell me which file i need to work on to change the source code. I know it will be not straight forward but you can tell me in a high level.

Noone has planned out such a thing, and a lot of things would be involved.

Ok understood and Thank you for your prompt responses.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.