diff --git a/bash/record.sh b/bash/record.sh index af86607..732f273 100755 --- a/bash/record.sh +++ b/bash/record.sh @@ -8,5 +8,5 @@ CURRENT_TIME=$(date +"%Y-%m-%d_%H-%M-%S") # 构建录像文件名 OUTPUT_FILE="${OUTPUT_DIR}/${CURRENT_TIME}.mp4" # 开始录制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}" diff --git a/create_db.py b/create_db.py index 4007805..a7d086e 100755 --- a/create_db.py +++ b/create_db.py @@ -27,4 +27,4 @@ try: add(t2) except Exception as e: print(e) - pass \ No newline at end of file + pass diff --git a/db/repository/__pycache__/lot_data_repository.cpython-310.pyc b/db/repository/__pycache__/lot_data_repository.cpython-310.pyc index c84e297..7e1c1f0 100644 Binary files a/db/repository/__pycache__/lot_data_repository.cpython-310.pyc and b/db/repository/__pycache__/lot_data_repository.cpython-310.pyc differ diff --git a/db/repository/lot_data_repository.py b/db/repository/lot_data_repository.py index 2647c6b..a8f55cd 100755 --- a/db/repository/lot_data_repository.py +++ b/db/repository/lot_data_repository.py @@ -36,8 +36,8 @@ def get_kb_detail_by_time(session, start_time, end_time): # 删除数据 @with_session -def delete_kb_detail_by_time(session, start_time, end_time): - d = session.query(LOT_DATA_MODEL).filter(start_time <= LOT_DATA_MODEL.create_time, LOT_DATA_MODEL.create_time <= end_time).delete() +def delete_kb_detail_by_time(session, end_time): + d = session.query(LOT_DATA_MODEL).filter(LOT_DATA_MODEL.create_time <= end_time).delete() return d diff --git a/delete_lot_data_3_days.py b/delete_lot_data_3_days.py new file mode 100644 index 0000000..1acc510 --- /dev/null +++ b/delete_lot_data_3_days.py @@ -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()