提交 95de3aaa authored 作者: zw.wang's avatar zw.wang

fix: 更新文件名

上级 1e9785af
...@@ -92,7 +92,8 @@ class StreamRecorder: ...@@ -92,7 +92,8 @@ class StreamRecorder:
record_result = self.recorder( record_result = self.recorder(
body['camera_index'], body['camera_index'],
datetime.strptime(body['start_time'], '%Y-%m-%dT%H:%M:%S').astimezone(tz), datetime.strptime(body['start_time'], '%Y-%m-%dT%H:%M:%S').astimezone(tz),
datetime.strptime(body['end_time'], '%Y-%m-%dT%H:%M:%S').astimezone(tz) datetime.strptime(body['end_time'], '%Y-%m-%dT%H:%M:%S').astimezone(tz),
body['camera_code']
) )
video_info, error_log = get_video_duration(record_result['file_name']) video_info, error_log = get_video_duration(record_result['file_name'])
...@@ -113,14 +114,21 @@ class StreamRecorder: ...@@ -113,14 +114,21 @@ class StreamRecorder:
return True return True
@staticmethod @staticmethod
def recorder(camera_index, start_time, end_time): def recorder(camera_index, start_time, end_time, camera_code):
"""
:param camera_index:
:param start_time: 开始时间,上海时区
:param end_time: 结束时间,上海时区
:param camera_code: 摄像头序列号
"""
playback_urls = client.get_cameras_playback_urls( playback_urls = client.get_cameras_playback_urls(
camera_index, camera_index,
HikVisionClient.iso_format(start_time), HikVisionClient.iso_format(start_time),
HikVisionClient.iso_format(end_time) HikVisionClient.iso_format(end_time)
) )
log.info('playback: %s', playback_urls) log.info('playback: %s', playback_urls)
file_name = os.path.join(video_path, 'rtmp_{}_{}.mp4'.format( file_name = os.path.join(video_path, 'ISC_{}_{}_{}.mp4'.format(
camera_code,
start_time.astimezone(pytz.utc).strftime('%Y%m%dT%H%M%S'), start_time.astimezone(pytz.utc).strftime('%Y%m%dT%H%M%S'),
end_time.astimezone(pytz.utc).strftime('%Y%m%dT%H%M%S') end_time.astimezone(pytz.utc).strftime('%Y%m%dT%H%M%S')
)) ))
...@@ -147,7 +155,8 @@ class StreamRecorder: ...@@ -147,7 +155,8 @@ class StreamRecorder:
if file_duration < complete_duration - 2: if file_duration < complete_duration - 2:
# 视频文件时长小于完整时长 # 视频文件时长小于完整时长
new_start_time = start_time + timedelta(seconds=file_duration) new_start_time = start_time + timedelta(seconds=file_duration)
part_file_name = os.path.join(video_path, 'rtmp_{}_{}_{}.mp4'.format( part_file_name = os.path.join(video_path, 'ISC_{}_{}_{}_{}.mp4'.format(
camera_code,
start_time.strftime('%Y%m%dT%H%M%S'), start_time.strftime('%Y%m%dT%H%M%S'),
new_start_time.strftime('%Y%m%dT%H%M%S'), part_num new_start_time.strftime('%Y%m%dT%H%M%S'), part_num
)) ))
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论