This commit is contained in:
xyj 2023-12-11 17:47:45 +08:00
parent a90818cdb3
commit 3285b85af7
5 changed files with 21 additions and 4 deletions

View File

@ -8,5 +8,5 @@ CURRENT_TIME=$(date +"%Y-%m-%d_%H-%M-%S")
# 构建录像文件名 # 构建录像文件名
OUTPUT_FILE="${OUTPUT_DIR}/${CURRENT_TIME}.mp4" OUTPUT_FILE="${OUTPUT_DIR}/${CURRENT_TIME}.mp4"
# 开始录制RTSP流 # 开始录制RTSP流
/usr/bin/ffmpeg -rtsp_transport tcp -i "${RTSP_URL}" -c copy -c:a aac -s 1920x1080 -r 15 -crf 35 -b:v 1250k -t "${RECORD_DURATION}" -f mp4 "${OUTPUT_FILE}" /usr/bin/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}"

View File

@ -27,4 +27,4 @@ try:
add(t2) add(t2)
except Exception as e: except Exception as e:
print(e) print(e)
pass pass

View File

@ -36,8 +36,8 @@ def get_kb_detail_by_time(session, start_time, end_time):
# 删除数据 # 删除数据
@with_session @with_session
def delete_kb_detail_by_time(session, start_time, end_time): def delete_kb_detail_by_time(session, end_time):
d = session.query(LOT_DATA_MODEL).filter(start_time <= LOT_DATA_MODEL.create_time, LOT_DATA_MODEL.create_time <= end_time).delete() d = session.query(LOT_DATA_MODEL).filter(LOT_DATA_MODEL.create_time <= end_time).delete()
return d return d

17
delete_lot_data_3_days.py Normal file
View File

@ -0,0 +1,17 @@
# 删除lot_data.db 保留三天的数据
import datetime
from db.repository import delete_kb_detail_by_time
def delete_data_3_days_ago():
try:
# 计算3天前的日期并转化为数据库格式
end_time = int((datetime.datetime.now() - datetime.timedelta(days=3)).timestamp())
d = delete_kb_detail_by_time(end_time)
except Exception as e:
pass
if __name__ == '__main__':
delete_data_3_days_ago()