diff --git a/include/record_manager.hpp b/include/record_manager.hpp index 88b0903..b918fc3 100644 --- a/include/record_manager.hpp +++ b/include/record_manager.hpp @@ -6,6 +6,8 @@ #include #include +#include "mp4v2/mp4v2.h" + struct RecordFileInfo { std::string stream; // AHD1_main diff --git a/src/main.cpp b/src/main.cpp index 34739cc..d5c165e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -21,6 +21,53 @@ static void signal_handler(int signum) write(STDERR_FILENO, msg, sizeof(msg) - 1); } +void test_mp4_info(const std::string& path) +{ + MP4FileHandle file = MP4Read(path.c_str()); + if (file == MP4_INVALID_FILE_HANDLE) + { + std::cerr << "Failed to open: " << path << std::endl; + return; + } + + std::cout << "=== MP4 Info for: " << path << " ===\n"; + + // duration (in seconds) + MP4Duration duration = MP4GetDuration(file); + uint32_t timeScale = MP4GetTimeScale(file); + double seconds = (double)duration / timeScale; + + std::cout << "Duration: " << seconds << " sec\n"; + + // video track + MP4TrackId videoTrack = MP4FindTrackId(file, 0, MP4_VIDEO_TRACK_TYPE); + if (videoTrack != MP4_INVALID_TRACK_ID) + { + uint32_t width = MP4GetTrackVideoWidth(file, videoTrack); + uint32_t height = MP4GetTrackVideoHeight(file, videoTrack); + + std::cout << "Video Track: YES\n"; + std::cout << "Resolution: " << width << " x " << height << "\n"; + } + else + { + std::cout << "Video Track: NO\n"; + } + + // audio track + MP4TrackId audioTrack = MP4FindTrackId(file, 0, MP4_AUDIO_TRACK_TYPE); + if (audioTrack != MP4_INVALID_TRACK_ID) + { + std::cout << "Audio Track: YES\n"; + } + else + { + std::cout << "Audio Track: NO\n"; + } + + MP4Close(file); +} + int main() { // ---------- 信号处理 ---------- @@ -74,6 +121,9 @@ int main() } } + test_mp4_info("/sata/record/AHD1_main/2025-11-13/10/10-24-17.mp4"); + test_mp4_info("/sata/record/AHD1_main/2025-11-13/10/10-25-17.mp4"); + // try // { // // 加载配置