diff --git a/record.sh b/record.sh index 8f7d68d..65d9ed7 100755 --- a/record.sh +++ b/record.sh @@ -1,3 +1,19 @@ #!/bin/bash -current_time=$(date +"%Y-%m-%d-%H-%M-%S") -ffmpeg -rtsp_transport tcp -i rtsp://admin:123456@192.168.0.123:554/mpeg4 -c:v libx265 -preset fast -crf 31 -c:a aac -vf scale=1920x1280:flags=lanczos -f mp4 segment -segment_time 900 /home/pi/mp4/file_$current_time.mp4 + +RTSP_URL="rtsp://admin:123456@192.168.0.123:554/mpeg4" # RTSP流的URL +OUTPUT_DIR="/home/pi/mp4" # 录像文件保存的目录 +RECORD_DURATION=60 # 录像时长(秒) +INTERNAL=1 +while true; do + # 获取当前时间 + CURRENT_TIME=$(date +"%Y-%m-%d_%H-%M-%S") + + # 构建录像文件名 + OUTPUT_FILE="${OUTPUT_DIR}/RECORD_${CURRENT_TIME}.mp4" + + # 开始录制RTSP流 + ffmpeg -rtsp_transport tcp -i "${RTSP_URL}" -c:v libx265 -vf scale=1920x1280:flags=lanczos -r 19 -crf 33 -c:a aac -t "${RECORD_DURATION}" -f mp4 "${OUTPUT_FILE}" + + # 等待1秒钟再开始录制 + sleep ${INTERNAL} +done \ No newline at end of file