@@ -145,14 +145,14 @@ function stop_recording() {
145
145
stop_ffmpeg
146
146
echo " $( date -u +" ${ts_format} " ) [${process_name} ] - Video recording stopped"
147
147
recorded_count=$(( recorded_count + 1 ))
148
+ recording_started=" false"
148
149
if [[ " ${VIDEO_UPLOAD_ENABLED} " = " true" ]] && [[ -n " ${UPLOAD_DESTINATION_PREFIX} " ]]; then
149
150
upload_destination=${UPLOAD_DESTINATION_PREFIX} /${video_file_name}
150
151
echo " $( date -u +" ${ts_format} " ) [${process_name} ] - Add to pipe a signal Uploading video to $upload_destination "
151
152
echo " $video_file ${UPLOAD_DESTINATION_PREFIX} " >> ${UPLOAD_PIPE_FILE} &
152
153
elif [[ " ${VIDEO_UPLOAD_ENABLED} " = " true" ]] && [[ -z " ${UPLOAD_DESTINATION_PREFIX} " ]]; then
153
154
echo " $( date -u +" ${ts_format} " ) [${process_name} ] - Upload destination not known since UPLOAD_DESTINATION_PREFIX is not set. Continue without uploading."
154
155
fi
155
- recording_started=" false"
156
156
}
157
157
158
158
function check_if_ffmpeg_running() {
@@ -182,7 +182,6 @@ function wait_for_file_integrity() {
182
182
function stop_if_recording_inprogress() {
183
183
if [[ " $recording_started " = " true" ]] || check_if_ffmpeg_running; then
184
184
stop_recording
185
- wait_for_file_integrity
186
185
fi
187
186
}
188
187
@@ -223,7 +222,6 @@ if [[ "${VIDEO_UPLOAD_ENABLED}" != "true" ]] && [[ "${VIDEO_FILE_NAME}" != "auto
223
222
if ps -p $FFMPEG_PID > /dev/null; then
224
223
wait $FFMPEG_PID
225
224
fi
226
- wait_for_file_integrity
227
225
228
226
else
229
227
trap graceful_exit_force SIGTERM SIGINT EXIT
@@ -247,34 +245,32 @@ else
247
245
video_file_name=" ${return_list[1]} .mp4"
248
246
endpoint_url=" ${return_list[2]} "
249
247
/opt/bin/validate_endpoint.sh " ${endpoint_url} " " true"
250
- echo " $( date -u +" ${ts_format} " ) [${process_name} ] - Start recording: $caps_se_video_record , video file name: $video_file_name "
251
- log_node_response
252
- fi
253
- if [[ " $session_id " != " null" && " $session_id " != " " && " $session_id " != " reserved" && " $recording_started " = " false" && " $caps_se_video_record " = " true" ]]; then
254
- video_file=" ${VIDEO_FOLDER} /$video_file_name "
255
- echo " $( date -u +" ${ts_format} " ) [${process_name} ] - Starting to record video"
256
- ffmpeg -hide_banner -loglevel warning -flags low_delay -threads 2 -fflags nobuffer+genpts -strict experimental -y -f x11grab \
257
- -video_size ${VIDEO_SIZE} -r ${FRAME_RATE} -i ${DISPLAY} ${SE_AUDIO_SOURCE} -codec:v ${CODEC} ${PRESET} -pix_fmt yuv420p " $video_file " &
258
- FFMPEG_PID=$!
259
- if ps -p $FFMPEG_PID > /dev/null; then
260
- recording_started=" true"
248
+ if [[ " $caps_se_video_record " = " true" ]]; then
249
+ echo " $( date -u +" ${ts_format} " ) [${process_name} ] - Start recording: $caps_se_video_record , video file name: $video_file_name "
250
+ log_node_response
251
+ video_file=" ${VIDEO_FOLDER} /$video_file_name "
252
+ echo " $( date -u +" ${ts_format} " ) [${process_name} ] - Starting to record video"
253
+ ffmpeg -hide_banner -loglevel warning -flags low_delay -threads 2 -fflags nobuffer+genpts -strict experimental -y -f x11grab \
254
+ -video_size ${VIDEO_SIZE} -r ${FRAME_RATE} -i ${DISPLAY} ${SE_AUDIO_SOURCE} -codec:v ${CODEC} ${PRESET} -pix_fmt yuv420p " $video_file " &
255
+ FFMPEG_PID=$!
256
+ if ps -p $FFMPEG_PID > /dev/null; then
257
+ recording_started=" true"
258
+ prev_session_id=$session_id
259
+ fi
260
+ echo " $( date -u +" ${ts_format} " ) [${process_name} ] - Video recording started"
261
+ sleep ${poll_interval}
261
262
fi
262
- echo " $( date -u +" ${ts_format} " ) [${process_name} ] - Video recording started"
263
- sleep ${poll_interval}
264
263
elif [[ " $session_id " != " $prev_session_id " && " $recording_started " = " true" ]]; then
265
264
stop_recording
266
- wait_for_file_integrity
267
265
if [[ $max_recorded_count -gt 0 ]] && [[ $recorded_count -ge $max_recorded_count ]]; then
268
266
echo " $( date -u +" ${ts_format} " ) [${process_name} ] - Node will be drained since max sessions reached count number ($max_recorded_count )"
269
267
exit
270
268
fi
271
269
elif [[ $recording_started = " true" ]]; then
272
270
echo " $( date -u +" ${ts_format} " ) [${process_name} ] - Video recording in progress"
273
271
sleep ${poll_interval}
274
- else
275
- sleep ${poll_interval}
276
272
fi
277
- prev_session_id=$session_id
278
273
done
274
+ stop_if_recording_inprogress
279
275
echo " $( date -u +" ${ts_format} " ) [${process_name} ] - Node API is not responding now, exiting..."
280
276
fi
0 commit comments