http://localhost:8080
GET /api/videos
响应示例:
{
"count": 10,
"videos": [
{
"filename": "test_stream1.mp4",
"full_path": "./output/20251011_082130/test_stream1.mp4",
"timestamp_dir": "20251011_082130",
"file_size": 787456,
"created_time": "2025-10-11 08:21:45",
"stream_index": "1"
}
]
}
GET /api/videos/{timestamp}
路径参数:
timestamp
: 时间戳目录名,例如 20251011_082130
GET /api/timestamps
响应示例:
{
"count": 5,
"timestamps": [
{
"timestamp": "20251011_082130",
"video_count": 2,
"total_size": 5748992
}
]
}
DELETE /api/timestamp/{timestamp}
路径参数:
timestamp
: 要删除的时间戳目录名响应示例:
{
"success": true,
"path": "./output/20251011_082130",
"message": "目录删除成功"
}
GET /api/reports
响应示例:
{
"count": 8,
"reports": [
{
"timestamp": "20251011_082130",
"has_report": true,
"summary": {
"total_streams": 2,
"successful_streams": 2,
"failed_streams": 0,
"cancelled_streams": 0,
"total_bytes": 0,
"total_frames": 950,
"success_rate": 1.0,
"average_duration": 18.0,
"earliest_start": "2025-10-11 08:21:30",
"latest_end": "2025-10-11 08:21:50"
},
"generated_at": "2025-10-11 08:21:50"
}
]
}
字段说明:
total_streams
: 总流数successful_streams
: 成功拉取的流数量failed_streams
: 失败的流数量cancelled_streams
: 取消的流数量success_rate
: 成功率 (0.0-1.0)total_frames
: 总接收帧数average_duration
: 平均持续时间(秒)GET /api/report/{timestamp}
路径参数:
timestamp
: 时间戳目录名响应示例:
{
"report_generated_at": "2025-10-11 08:21:50",
"config": {
"global_config": {
"total_poll_duration_seconds": 60,
"max_concurrent_streams": 2,
"output_directory": "./output/20251011_082130"
},
"streams": [...]
},
"scheduler_stats": {
"total_tasks": 2,
"completed_tasks": 2,
"failed_tasks": 0,
"cancelled_tasks": 0
},
"streams": [
{
"stream_index": 1,
"rtsp_url": "rtsp://example.com/stream1",
"output_file": "./output/20251011_082130/test_stream2.mp4",
"status": "完成",
"start_time": "2025-10-11 08:21:30",
"end_time": "2025-10-11 08:21:50",
"bytes_received": 0,
"frames_received": 549,
"duration_seconds": 20,
"error_message": "",
"actual_duration_seconds": 20
}
],
"summary": {
"total_streams": 2,
"successful_streams": 2,
"failed_streams": 0,
"total_frames": 950,
"success_rate": 1.0
}
}
流状态说明:
完成
: 流成功拉取失败
: 流拉取失败(会有error_message)取消
: 流被取消DELETE /api/video?path={path}
查询参数:
path
: 视频文件的完整路径响应示例:
{
"success": true,
"path": "./output/20251011_082130/test_stream1.mp4",
"message": "文件删除成功"
}
GET /videos/{timestamp}/{filename}
路径参数:
timestamp
: 时间戳目录名filename
: 视频文件名功能: 直接返回视频文件流,支持浏览器播放和下载
GET /
系统主页,提供快速导航
GET /manager
完整的视频和报告管理界面,包括:
所有错误响应遵循以下格式:
{
"error": "错误类型",
"message": "详细错误信息"
}
常见HTTP状态码:
200 OK
: 请求成功400 Bad Request
: 请求参数错误403 Forbidden
: 权限不足404 Not Found
: 资源不存在500 Internal Server Error
: 服务器内部错误curl http://localhost:8080/api/reports
curl http://localhost:8080/api/report/20251011_082130
curl -X DELETE "http://localhost:8080/api/video?path=./output/20251011_082130/test_stream1.mp4"
// 获取所有报告
async function loadReports() {
const response = await fetch('http://localhost:8080/api/reports');
const data = await response.json();
console.log(`共有 ${data.count} 个报告`);
return data.reports;
}
// 获取特定报告
async function getReport(timestamp) {
const response = await fetch(`http://localhost:8080/api/report/${timestamp}`);
const report = await response.json();
return report;
}
/api/reports
, /api/report/{timestamp}
)