[英]How to find the Creation time of a .wav file using C++
我目前正在使用 C++ 讀取 RIff fmt .wav 文件。 我怎么能找到文件創建的日期和時間。 標頭中包含的唯一時間是TimeStamp
,它表示自紀元以來的秒數。
以下是我正在使用的解析 RIff 標頭:
typedef struct RIFF_CHUNCK_DISCRIPTOR {
char RIFF[4]; // RIFF Header Magic header
int32_t ChunkSize; // RIFF Chunk Size
int32_t WAVE[4]; // WAVE Header
};
typedef struct CRIF_CHUNCK {
char Crif[4];
int32_t Length;
int32_t CrifCheckSum;
};
typedef struct FMT_CHUNCK_DISCRIPTOR {
char fmt[4]; // FMT header
int32_t Subchunk1Size; // Size of the fmt chunk
int16_t EncodingTag;
int16_t NumOfChan; // Number of channels
int32_t SamplesPerSec; // Sampling Frequency in Hz
int32_t bytesPerSec; // bytes per second
int16_t blockAlign; // 2=16-bit mono, 4=16-bit stereo
int16_t bitsPerSample; // Number of bits per sample
int16_t AudioFormat; // PCM = 0 , ADPCM = 2
int16_t SmplesPerChan;
};typedef struct FMT_CHUNCK_DISCRIPTOR_PCM {
char fmt[4]; // FMT header
int32_t Subchunk1Size; // Size of the fmt chunk
int16_t EncodingTag;
int16_t NumOfChan; // Number of channels
int32_t SamplesPerSec; // Sampling Frequency in Hz
int32_t bytesPerSec; // bytes per second
int16_t blockAlign; // 2=16-bit mono, 4=16-bit stereo
int16_t bitsPerSample; // Number of bits per sample
int16_t AudioFormat; // PCM = 0 , ADPCM = 2
};
typedef struct FACT_CHUNCK {
char fact[4];
int32_t FactSize;
int32_t dwSampleLength;
};
typedef struct META_DATA {
char meta[4];
uint32_t HeadData;// <length of the head data - 8>
uint8_t Version;
uint8_t Model;
uint32_t Serial;
uint32_t RecordingNumber;
uint16_t ChunkNumber;
uint32_t TimeStamp;
uint32_t MetadataChecksum;
};
typedef struct DATA_SUB_CHUNCK {
char Subchunk2ID[4]; // "data" string
int32_t Subchunk2Size; // Sampled data length
};
typedef struct CDAT {
char cdat[4]; // "data" string
int32_t CdatCheckSum; // Sampled data length
};
typedef struct FOOTER {
char foot[4]; // "data" string
int16_t PrevChunckNumb; // Sampled data length
int16_t NextChunckNumb;
int32_t FooterChunckSum;
};
WAV 文件元數據中的Timestamp
字段和文件創建日期是不相關的信息。
文件創建日期是文件在硬盤驅動器上創建的日期。 您可以使用 Windows API GetFileTime
來獲取創建時間、上次訪問時間和上次寫入時間。
Timestamp
只是某人放入 WAV 文件中的一些信息。 它可能存在也可能不存在,並且可能與您使用GetFileTime
獲得的時間/日期信息相同,也可能不同。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.