【问题标题】:How to find the Creation time of a .wav file using C++如何使用 C++ 查找 .wav 文件的创建时间
【发布时间】:2021-12-22 05:32:09
【问题描述】:

我目前正在使用 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;


};


【问题讨论】:

  • Timestamp 不是创建时间戳吗?你知道时代是什么吗?

标签: c++ wav riff


【解决方案1】:

WAV 文件元数据中的Timestamp 字段和文件创建日期是不相关的信息。

文件创建日期是文件在硬盘上创建的日期。您可以使用 Windows API GetFileTime 获取创建、上次访问和上次写入时间。

Timestamp 只是有人放入 WAV 文件中的一些信息。它可能存在也可能不存在,可能与您通过GetFileTime 获得的时间/日期信息相同,也可能不同。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-02-20
    • 1970-01-01
    • 2013-06-20
    • 2015-01-19
    • 1970-01-01
    • 2017-01-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多