当前位置:首页 > 编程笔记 > 正文
已解决

音频格式WAV

来自网友在路上 156856提问 提问时间:2023-10-24 14:00:09阅读次数: 56

最佳答案 问答题库568位专家为你答疑解惑

查找wav文件头关键struct 位置,当然也可查找avi文件头。用这个方法找到avi文件data位置后,可直接读出文件的每一帧图片。当然avi数据的标志位不是data,可以是00dc等。

WAV音频头文件有三个关键struct:RIFF, fmt,data。

AVI 视频文件头的关键struct:RIFF, LIST, avih,movi,strl,strh,strf.

 

 


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <malloc.h>
#include <wait.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/mman.h>int main(void){FILE *f=fopen("/home/wjs/2.wav","r");fseek(f, 0, SEEK_END);int size = ftell(f);fseek(f, 0, SEEK_SET);int fd=open("/home/wjs/2.wav",O_RDONLY);char *m=mmap(NULL,size,PROT_READ,MAP_SHARED,fd,0);for(int t=0;t<size;t++){if((m[t]=='R')&&(m[t+1]=='I')&&(m[t+2]=='F')&&(m[t+3])=='F'){printf("RIFF:%d\n",t);}}for(int t=0;t<size;t++){if((m[t]=='f')&&(m[t+1]=='m')&&(m[t+2]=='t')){printf("fmt:%d\n",t);}}for(int t=0;t<size;t++){if((m[t]=='d')&&(m[t+1]=='a')&&(m[t+2]=='t')&&(m[t+3])=='a'){printf("data:%d\n",t);}}munmap(m,size);puts("over");return 0;}

 

 

 

 

查看全文

99%的人还看了

猜你感兴趣

版权申明

本文"音频格式WAV":http://eshow365.cn/6-23391-0.html 内容来自互联网,请自行判断内容的正确性。如有侵权请联系我们,立即删除!