@@ -14,7 +14,7 @@ VIDEO_CONFIG_DIRECTORY=${VIDEO_CONFIG_DIRECTORY:-"/opt/bin"}
1414UPLOAD_DESTINATION_PREFIX=${UPLOAD_DESTINATION_PREFIX:- $SE_UPLOAD_DESTINATION_PREFIX }
1515UPLOAD_PIPE_FILE_NAME=${SE_UPLOAD_PIPE_FILE_NAME:- " uploadpipe" }
1616SE_SERVER_PROTOCOL=${SE_SERVER_PROTOCOL:- " http" }
17- poll_interval=${SE_VIDEO_POLL_INTERVAL:- 1 }
17+ poll_interval=${SE_VIDEO_POLL_INTERVAL:- 2 }
1818max_attempts=${SE_VIDEO_WAIT_ATTEMPTS:- 50}
1919file_ready_max_attempts=${SE_VIDEO_FILE_READY_WAIT_ATTEMPTS:- 5}
2020wait_uploader_shutdown_max_attempts=${SE_VIDEO_WAIT_UPLOADER_SHUTDOWN_ATTEMPTS:- 5}
@@ -229,8 +229,11 @@ if [[ "${VIDEO_UPLOAD_ENABLED}" != "true" ]] && [[ "${VIDEO_FILE_NAME}" != "auto
229229 wait_for_display
230230 video_file=" $VIDEO_FOLDER /$VIDEO_FILE_NAME "
231231 # exec replaces the video.sh process with ffmpeg, this makes easier to pass the process termination signal
232- ffmpeg -hide_banner -loglevel warning -flags low_delay -threads 2 -fflags nobuffer+genpts -strict experimental -y -f x11grab \
233- -video_size ${VIDEO_SIZE} -r ${FRAME_RATE} -i ${DISPLAY} ${SE_AUDIO_SOURCE} -codec:v ${CODEC} ${PRESET} -pix_fmt yuv420p " $video_file " &
232+ ffmpeg -hide_banner -loglevel warning -threads ${SE_FFMPEG_THREADS:- 1} -thread_queue_size 512 \
233+ -probesize 32M -analyzeduration 0 -y -f x11grab -video_size ${VIDEO_SIZE} -r ${FRAME_RATE} \
234+ -i ${DISPLAY} ${SE_AUDIO_SOURCE} -codec:v ${CODEC} ${PRESET:- " -preset veryfast" } \
235+ -tune zerolatency -crf ${SE_VIDEO_CRF:- 28} -maxrate ${SE_VIDEO_MAXRATE:- 1000k} -bufsize ${SE_VIDEO_BUFSIZE:- 2000k} \
236+ -pix_fmt yuv420p -movflags +faststart " $video_file " &
234237 FFMPEG_PID=$!
235238 if ps -p $FFMPEG_PID > /dev/null; then
236239 wait $FFMPEG_PID
@@ -262,8 +265,11 @@ else
262265 log_node_response
263266 video_file=" ${VIDEO_FOLDER} /$video_file_name "
264267 echo " $( date -u +" ${ts_format} " ) [${process_name} ] - Starting to record video"
265- ffmpeg -hide_banner -loglevel warning -flags low_delay -threads 2 -fflags nobuffer+genpts -strict experimental -y -f x11grab \
266- -video_size ${VIDEO_SIZE} -r ${FRAME_RATE} -i ${DISPLAY} ${SE_AUDIO_SOURCE} -codec:v ${CODEC} ${PRESET} -pix_fmt yuv420p " $video_file " &
268+ ffmpeg -hide_banner -loglevel warning -threads ${SE_FFMPEG_THREADS:- 1} -thread_queue_size 512 \
269+ -probesize 32M -analyzeduration 0 -y -f x11grab -video_size ${VIDEO_SIZE} -r ${FRAME_RATE} \
270+ -i ${DISPLAY} ${SE_AUDIO_SOURCE} -codec:v ${CODEC} ${PRESET:- " -preset veryfast" } \
271+ -tune zerolatency -crf ${SE_VIDEO_CRF:- 28} -maxrate ${SE_VIDEO_MAXRATE:- 1000k} -bufsize ${SE_VIDEO_BUFSIZE:- 2000k} \
272+ -pix_fmt yuv420p -movflags +faststart " $video_file " &
267273 FFMPEG_PID=$!
268274 if ps -p $FFMPEG_PID > /dev/null; then
269275 recording_started=" true"
281287 elif [[ $recording_started = " true" ]]; then
282288 echo " $( date -u +" ${ts_format} " ) [${process_name} ] - Video recording in progress"
283289 sleep ${poll_interval}
290+ else
291+ sleep ${poll_interval}
284292 fi
285293 done
286294 stop_if_recording_inprogress
0 commit comments