This commit is contained in:
xyj 2023-12-04 18:21:47 +08:00
parent 295e402b9e
commit 94ee8ae79a
3 changed files with 23 additions and 12 deletions

13
conf/record_cron.conf Normal file
View File

@ -0,0 +1,13 @@
[program:record_cron]
directory=/home/pi/lot_manager
command=supervisorctl start record
user=pi
;是否随开机自启 或者reload自启动
autostart=true
;失败重启
autorestart=true
;重启次数
restart_times=3
redirect_stderr=true
stopsignal=TERM
stopasgroup=True

View File

@ -3,16 +3,10 @@
RTSP_URL="rtsp://admin:123456@192.168.0.123:554/mpeg4" # RTSP流的URL
OUTPUT_DIR="/home/pi/mp4" # 录像文件保存的目录
RECORD_DURATION=900 # 录像时长(秒)
INTERNAL=1
while true; do
# 获取当前时间
CURRENT_TIME=$(date +"%Y-%m-%d_%H-%M-%S")
# 获取当前时间
CURRENT_TIME=$(date +"%Y-%m-%d_%H-%M-%S")
# 构建录像文件名
OUTPUT_FILE="${OUTPUT_DIR}/${CURRENT_TIME}.mp4"
# 开始录制RTSP流
ffmpeg -rtsp_transport tcp -i "${RTSP_URL}" -c copy -c:a aac -s 1920x1080 -r 15 -crf 35 -t "${RECORD_DURATION}" -f mp4 "${OUTPUT_FILE}"
# 构建录像文件名
OUTPUT_FILE="${OUTPUT_DIR}/${CURRENT_TIME}.mp4"
# 开始录制RTSP流
ffmpeg -rtsp_transport tcp -i "${RTSP_URL}" -c copy -c:a aac -s 1920x1080 -r 15 -crf 35 -t "${RECORD_DURATION}" -f mp4 "${OUTPUT_FILE}"
# 等待1秒钟再开始录制
sleep ${INTERNAL}
done

4
record_cron.sh Executable file
View File

@ -0,0 +1,4 @@
#!/bin/bash
supervisorctl start