#include #include "include/rtsp_client.h" #include "include/config.h" using namespace jtjai_media; int main() { std::cout << "测试文件大小统计修复" << std::endl; // 创建测试配置 StreamConfig test_config; test_config.rtsp_url = "rtsp://218.94.57.146:40007/rtp/44010200492000000074_34020000001320000001"; test_config.duration_seconds = 5; // 短时间测试 test_config.weight = 1.0; test_config.output_filename = "test_file_size.mp4"; // 创建输出目录 std::string output_dir = "./test_output"; std::filesystem::create_directories(output_dir); // 创建RTSP客户端 RTSPClient client(0, test_config, output_dir); std::cout << "开始录制测试..." << std::endl; bool success = client.start_recording(5); // 获取统计信息 auto stats = client.get_stats(); std::cout << "\n=== 录制结果 ===" << std::endl; std::cout << "状态: " << static_cast(stats.status) << std::endl; std::cout << "输出文件: " << stats.output_file << std::endl; std::cout << "接收字节数: " << stats.bytes_received << std::endl; std::cout << "接收帧数: " << stats.frames_received << std::endl; // 验证文件是否存在并检查实际大小 if (std::filesystem::exists(stats.output_file)) { auto actual_file_size = std::filesystem::file_size(stats.output_file); std::cout << "实际文件大小: " << actual_file_size << " 字节" << std::endl; if (stats.bytes_received > 0) { std::cout << "✅ 文件大小统计正常!" << std::endl; } else { std::cout << "❌ 文件大小统计仍为0" << std::endl; } } else { std::cout << "⚠️ 文件未创建" << std::endl; } return 0; }