on_record_hook script taking too long

Taylor

Member
Hello

We are trying to use the on_record_hook script to post-process our recorded streams with ffmpeg and then copy the processed videos to an S3 bucket.

However we are getting an issue on the front end where the user completes the recording but is waiting a long time for the STREAM_STATUS.UNPUBLISHED event to be sent back. It takes anywhere between 1 minute to 3 minutes and, in some cases, the stream object returned has no value when calling getRecordInfo()

We've tried having the on_record_hook script to run ffmpeg and then copy the file asynchronously by calling a separate script like so in the background:
Code:
nohup /bin/bash ./script_to_run_ffmpeg.sh $1 $2 &
But despite using nohup, puting job in background (&), calling with '/bin/bash' or 'sh', it still doesn't work.
The STREAM_STATUS.UNPUBLISHED event still takes too long to be sent back, confirming that it's still waiting for the ffmpeg command inside the separate script to complete.

Ideally the solution we want is that when stream recording is finished, UNPUBLISHED event is immediately sent back to the front-end, while a separate script asynchronously runs the ffmpeg script and then copies the video to the S3 bucket.

Is there a way we can achieve this desired result?

Additionally is it possible for the STREAM_STATUS.UNPUBLISHED event to be returned before the on_record_hook script is fully complete?
If so, would that mean the stream.getRecordInfo() method would return null in that event?

Cheers
 

Max

Administrator
Staff member
Good day.
Please set the following parameter to limit the waiting time (for example, 15 seconds)
Code:
record_stop_timeout=15
If so, would that mean the stream.getRecordInfo() method would return null in that event?
Yes, if client receive UNPUBLISHED event before a recording file is saved to disk, stream.getRecordInfo() method will return null.
 
Top