繁体   English   中英

如何使用 C++ 查找 .wav 文件的创建时间

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM