我正在将Flac文件解码为波形文件。解码文件后,我通过此代码获取流信息
void metadata_callback(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data)
{
(void)decoder, (void)client_data;
/* print some stats */
if(metadata->type == FLAC__METADATA_TYPE_STREAMINFO) {
/* save for later */
total_samples = metadata->data.stream_info.total_samples;
sample_rate = metadata->data.stream_info.sample_rate;
channels = metadata->data.stream_info.channels;
bps = metadata->data.stream_info.bits_per_sample;
fprintf(stderr, "sample rate : %u Hz\n", sample_rate);
fprintf(stderr, "channels : %u\n", channels);
fprintf(stderr, "bits per sample: %u\n", bps);
#ifdef _MSC_VER
fprintf(stderr, "total samples : %I64u\n", total_samples);
#else
fprintf(stderr, "total samples : %llu\n", total_samples);
#endif
}
现在我想获取相册名称,图片,艺术家名称等元数据。
为此我尝试了这段代码
FLAC__StreamMetadata *tags;
FLAC__bool success = FLAC__metadata_get_tags(infilePath, &tags);
if (success) {
printf("Got stream information");
printf("metadata %u",tags->data.vorbis_comment.num_comments);
}else {
printf("Failed to get stream information");
}
但是我在控制台上获得零,即0。请帮忙。