This commit is contained in:
xyj 2023-12-04 09:47:02 +08:00
parent c378b2706a
commit 6f75266310
1 changed files with 2 additions and 2 deletions

View File

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