1
This commit is contained in:
parent
122c3344a8
commit
119034f1b4
@ -6,6 +6,8 @@
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
#include "mp4v2/mp4v2.h"
|
||||
|
||||
struct RecordFileInfo
|
||||
{
|
||||
std::string stream; // AHD1_main
|
||||
|
||||
50
src/main.cpp
50
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
|
||||
// {
|
||||
// // 加载配置
|
||||
|
||||
Loading…
Reference in New Issue
Block a user