lot_manager/record.sh

18 lines
593 B
Bash
Raw Normal View History

2023-12-02 13:22:57 +08:00
#!/bin/bash
2023-12-02 17:22:43 +08:00
RTSP_URL="rtsp://admin:123456@192.168.0.123:554/mpeg4" # RTSP流的URL
OUTPUT_DIR="/home/pi/mp4" # 录像文件保存的目录
2023-12-02 19:44:06 +08:00
RECORD_DURATION=900 # 录像时长(秒)
2023-12-04 09:47:02 +08:00
INTERNAL=1
2023-12-02 17:22:43 +08:00
while true; do
# 获取当前时间
CURRENT_TIME=$(date +"%Y-%m-%d_%H-%M-%S")
# 构建录像文件名
2023-12-02 17:22:59 +08:00
OUTPUT_FILE="${OUTPUT_DIR}/${CURRENT_TIME}.mp4"
2023-12-02 17:22:43 +08:00
# 开始录制RTSP流
2023-12-04 10:12:04 +08:00
ffmpeg -rtsp_transport tcp -i "${RTSP_URL}" -c copy -c:a aac -s 1920x1080 -r 18 -crf 34 -t "${RECORD_DURATION}" -f mp4 "${OUTPUT_FILE}"
2023-12-02 17:22:43 +08:00
# 等待1秒钟再开始录制
sleep ${INTERNAL}
done