@@ -204,14 +204,23 @@ function graceful_exit_force() {
204204 exit 0
205205}
206206
207+ if [ " ${SE_RECORD_AUDIO,,} " = " true" ]; then
208+ echo " $( date -u +" ${ts_format} " ) [${process_name} ] - Audio source arguments: ${SE_AUDIO_SOURCE} "
209+ else
210+ SE_AUDIO_SOURCE=" "
211+ fi
212+
207213if [[ " ${VIDEO_UPLOAD_ENABLED} " != " true" ]] && [[ " ${VIDEO_FILE_NAME} " != " auto" ]] && [[ -n " ${VIDEO_FILE_NAME} " ]]; then
208214 trap graceful_exit SIGTERM SIGINT EXIT
209215 wait_for_display
210216 video_file=" $VIDEO_FOLDER /$VIDEO_FILE_NAME "
211217 # exec replaces the video.sh process with ffmpeg, this makes easier to pass the process termination signal
212218 ffmpeg -hide_banner -loglevel warning -flags low_delay -threads 2 -fflags nobuffer+genpts -strict experimental -y -f x11grab \
213- -video_size ${VIDEO_SIZE} -r ${FRAME_RATE} -i ${DISPLAY} -codec:v ${CODEC} ${PRESET} -pix_fmt yuv420p " $video_file " &
214- wait $!
219+ -video_size ${VIDEO_SIZE} -r ${FRAME_RATE} -i ${DISPLAY} ${SE_AUDIO_SOURCE} -codec:v ${CODEC} ${PRESET} -pix_fmt yuv420p " $video_file " &
220+ FFMPEG_PID=$!
221+ if ps -p $FFMPEG_PID > /dev/null; then
222+ wait $FFMPEG_PID
223+ fi
215224 wait_for_file_integrity
216225
217226else
@@ -243,8 +252,11 @@ else
243252 video_file=" ${VIDEO_FOLDER} /$video_file_name "
244253 echo " $( date -u +" ${ts_format} " ) [${process_name} ] - Starting to record video"
245254 ffmpeg -hide_banner -loglevel warning -flags low_delay -threads 2 -fflags nobuffer+genpts -strict experimental -y -f x11grab \
246- -video_size ${VIDEO_SIZE} -r ${FRAME_RATE} -i ${DISPLAY} -codec:v ${CODEC} ${PRESET} -pix_fmt yuv420p " $video_file " &
247- recording_started=" true"
255+ -video_size ${VIDEO_SIZE} -r ${FRAME_RATE} -i ${DISPLAY} ${SE_AUDIO_SOURCE} -codec:v ${CODEC} ${PRESET} -pix_fmt yuv420p " $video_file " &
256+ FFMPEG_PID=$!
257+ if ps -p $FFMPEG_PID > /dev/null; then
258+ recording_started=" true"
259+ fi
248260 echo " $( date -u +" ${ts_format} " ) [${process_name} ] - Video recording started"
249261 sleep ${poll_interval}
250262 elif [[ " $session_id " != " $prev_session_id " && " $recording_started " = " true" ]]; then
0 commit comments