C語(yǔ)言實(shí)現(xiàn)為無(wú)聲avi視頻添加wave音樂(lè)
編程中發(fā)現(xiàn),頭文件結(jié)構(gòu)中很多參數(shù)要求很不嚴(yán)格,只有少數(shù)幾個(gè)很重要,
其實(shí),這個(gè)程序就是為后期的用攝像頭錄像,麥克風(fēng)錄音作準(zhǔn)備的,此程序用的音頻我就是用麥克風(fēng)錄制的。
現(xiàn)在此程序生成的avi 可以被deepin的 自帶視頻播放軟件播放了。
我理解,單位時(shí)間內(nèi),視頻和音頻交叉的數(shù)據(jù)的播放時(shí)間要相等。單位內(nèi)音頻和視頻可以多次交叉,也可交叉一次。
每一段交叉的音頻視頻數(shù)據(jù)前必須要要加數(shù)據(jù)類型標(biāo)識(shí)xxdc,xxwb和數(shù)據(jù)長(zhǎng)度。告訴播放器下面的數(shù)據(jù)是什麼類型,有多長(zhǎng)。
#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> static int ap; static int at; static int nframe = 0; static unsigned int vzj = 0; static unsigned int azj = 0; //下面7個(gè)參數(shù)必須要先定義 #define zwidth 720 #define zheigth 496 #define zvrate 30 //video 幀率 #define channal 2 //audio 頻道數(shù) #define zarate 44100 //audio 采樣率 #define bitper 16 //audio 采樣寬度 #define vbitper 24 //video 采樣寬度 int main(void) { struct file { struct riff { char id[4]; unsigned int size; char type[4]; struct hdrl { char id[4]; unsigned int size; unsigned char type[4]; struct avih { unsigned char id[4]; //塊ID,固定為avih unsigned int size; //塊大小,等于struct avi_avih_chunk去掉id和size的大小 unsigned int us_per_frame; //視頻幀間隔時(shí)間(以微秒為單位) unsigned int max_bytes_per_sec; //AVI文件的最大數(shù)據(jù)率 unsigned int padding; //設(shè)為0即可 unsigned int flags; //AVI文件全局屬性,如是否含有索引塊、音視頻數(shù)據(jù)是否交叉存儲(chǔ)等 unsigned int total_frames; //總幀數(shù) unsigned int init_frames; //為交互格式指定初始幀數(shù)(非交互格式應(yīng)該指定為0) unsigned int streams; //文件包含的流的個(gè)數(shù),僅有視頻流時(shí)為1 unsigned int suggest_buff_size; //指定讀取本文件建議使用的緩沖區(qū)大小,通常為存儲(chǔ)一楨圖像 unsigned int width; //視頻主窗口寬度(單位:像素) unsigned int height; //視頻主窗口高度(單位:像素) unsigned int reserved[4]; //保留段,設(shè)為0即可 } av; struct strl { unsigned char id[4]; //塊ID,固定為L(zhǎng)IST unsigned int size; //塊大小,等于struct avi_strl_list去掉id和size的大小 unsigned char type[4]; //strl struct strh1 { unsigned char id[4]; //塊ID,固定為strh unsigned int size; //塊大小,等于struct avi_strh_chunk去掉id和size的大小 unsigned char stream_type[4]; //流的類型,vids表示視頻流,auds表示音頻流 unsigned char codec[4]; //指定處理這個(gè)流需要的解碼器,如JPEG unsigned int flags; //標(biāo)記,如是否允許這個(gè)流輸出、調(diào)色板是否變化等,一般設(shè)為0即可 unsigned short priority; //流的優(yōu)先級(jí),視頻流設(shè)為0即可 unsigned short language; //音頻語(yǔ)言代號(hào),視頻流設(shè)為0即可 unsigned int init_frames; //為交互格式指定初始幀數(shù)(非交互格式應(yīng)該指定為0) unsigned int scale; // unsigned int rate; //對(duì)于視頻流,rate / scale = 幀率fps unsigned int start; //對(duì)于視頻流,設(shè)為0即可 unsigned int length; //對(duì)于視頻流,length即總幀數(shù) unsigned int suggest_buff_size; //讀取這個(gè)流數(shù)據(jù)建議使用的緩沖區(qū)大小 unsigned int quality; //流數(shù)據(jù)的質(zhì)量指標(biāo) unsigned int sample_size; //音頻采樣大小,視頻流設(shè)為0即可 short left; //這個(gè)流在視頻主窗口中的顯示位置,設(shè)為{0,0,width,height}即可 short top; short right; short bottom; } sh1; struct strf1 { unsigned char id[4]; //塊ID,固定為strf unsigned int size; //塊大小,等于struct avi_strf_chunk去掉id和size的大小 //_BITMAPINFOHEADER 結(jié)構(gòu) int size1; // 指定結(jié)構(gòu)所需的字節(jié)數(shù)。=size unsigned int width; //指定位圖的寬度(以像素為單位)。 unsigned int height; //指定位圖的高度(以像素為單位) unsigned short planes; //指定目標(biāo)設(shè)備的平面數(shù)。 此值必須設(shè)置為 1。 unsigned short bitcount; //每個(gè)像素占的位數(shù),只能是1、4、8、16、24和32中的一個(gè) unsigned char compression[4]; //指定壓縮的自下而上位圖的壓縮類型 unsigned int image_size; //指定圖像的大?。ㄒ宰止?jié)為單位),等于width * height * bitcount / 8 unsigned int x_pixels_per_meter; //顯示設(shè)備的水平分辨率,設(shè)為0即可 unsigned int y_pixels_per_meter; //顯示設(shè)備的垂直分辨率,設(shè)為0即可 unsigned int num_colors; //含義不清楚,設(shè)為0即可 unsigned int imp_colors; //含義不清楚,設(shè)為0即可 } sf1; } sl1; struct strl2 { unsigned char id[4]; //塊ID,固定為L(zhǎng)IST unsigned int size; //塊大小,等于struct avi_strl_list去掉id和size的大小 unsigned char type[4]; //strl struct strh2 { unsigned char id[4]; //塊ID,固定為strh unsigned int size; //塊大小,等于struct avi_strh_chunk去掉id和size的大小 unsigned char stream_type[4]; //流的類型,vids表示視頻流,auds表示音頻流 unsigned char codec[4]; //指定處理這個(gè)流需要的解碼器,如JPEG unsigned int flags; //標(biāo)記,如是否允許這個(gè)流輸出、調(diào)色板是否變化等,一般設(shè)為0即可 unsigned short priority; //流的優(yōu)先級(jí),視頻流設(shè)為0即可 unsigned short language; //音頻語(yǔ)言代號(hào),視頻流設(shè)為0即可 unsigned int init_frames; //為交互格式指定初始幀數(shù)(非交互格式應(yīng)該指定為0) unsigned int scale; // unsigned int rate; //對(duì)于視頻流,rate / scale = 幀率fps unsigned int start; //對(duì)于視頻流,設(shè)為0即可 unsigned int length; //對(duì)于視頻流,length即總幀數(shù) unsigned int suggest_buff_size; //讀取這個(gè)流數(shù)據(jù)建議使用的緩沖區(qū)大小 unsigned int quality; //流數(shù)據(jù)的質(zhì)量指標(biāo) unsigned int sample_size; //音頻采樣大小,視頻流設(shè)為0即可 short left; //這個(gè)流在視頻主窗口中的顯示位置,設(shè)為{0,0,width,height}即可 short top; short right; short bottom; } sh2; struct strf2 { char id[4]; //strf int size; short wFormatTag; //波形音頻格式類型,格式標(biāo)記在 Microsoft Corporation 中注冊(cè),用于許多壓縮算法, short nChannels; //聲道數(shù) 85= WAVE_FORMAT_PCM int nSamplesPerSec; //采樣率,以每秒樣本數(shù) (赫) ,常見(jiàn)值為 8.0 kHz、11.025 kHz、22.05 kHz 和 44.1 kHz int nAvgBytesPerSec; //格式標(biāo)記所需的平均數(shù)據(jù)傳輸速率(以字節(jié)/秒為單位)=nsam*nblock short nBlockAlign; //阻止對(duì)齊(以字節(jié)為單位),nBlockAlign 必須等于 nChannels 和 wBitsPerSample 的乘積除以 8 (位/字節(jié)) short wBitsPerSample;// 如果 wFormatTag WAVE_FORMAT_PCM,則 wBitsPerSample 應(yīng)等于 8 或 16 short biSize; //追加到 WAVEFORMATEX 結(jié)構(gòu)末尾的額外格式信息的大?。ㄒ宰止?jié)為單位) } sf2; } sl2; } hd; struct movi { char id[4]; unsigned int size; char type[4]; } mo; } ri; } head; FILE *fo = fopen("/home/wjs/Videos/demo.avi", "w+b"); //生成avi FILE *f = fopen("/home/wjs/Videos/tra_mjpg.avi", "r+b"); //無(wú)聲視頻文件 FILE *af = fopen("/home/wjs/Music/15s.wav", "r+b"); //wav 文件 fseek(fo, sizeof(head), SEEK_SET); if (f == NULL) { puts("file_in error"); exit(-1); } if (af == NULL) { puts("file2_in error"); exit(-1); } fseek(f, 0, SEEK_END); int flen = ftell(f); fseek(f, 0, SEEK_SET); fseek(af, 0, SEEK_END); int aflen = ftell(af); fseek(af, 0, SEEK_SET); int tf = fileno(f); int taf = fileno(af); char *mf = mmap(NULL, flen, PROT_READ | PROT_WRITE, MAP_SHARED, tf, 0); char *maf = mmap(NULL, aflen, PROT_READ | PROT_WRITE, MAP_SHARED, taf, 0); for (int a = 0; a < aflen; a++) { if ((maf[a] == 'd') && (maf[a + 1] == 'a') && (maf[a + 2] == 't') && (maf[a + 3] == 'a')) { ap = a + 4 + 4; at = ap; } } int t = 0; while (t < flen) { int n = 0; while ((n <zvrate) && (t < flen)) { if ((mf[t] == '0') && (mf[t + 1] == '0') && (mf[t + 2] == 'd') && (mf[t + 3]) == 'c') { char c00dc[] = {'0', '0', 'd', 'c'}; fwrite(c00dc, 4, 1, fo); fwrite(&mf[t + 4], 4, 1, fo); //寫(xiě)長(zhǎng)度 int dx = 0; memcpy(&dx, &mf[t + 4], 4); fwrite(&mf[t + 8], dx, 1, fo); //寫(xiě)數(shù)據(jù) vzj = vzj + 8 + dx; n++; t++; nframe++; } else { t++; } } //------------------------ 以一秒為單位,視頻,音頻數(shù)據(jù)交叉一次------------------------------------------------ char c01wb[] = {'0', '1', 'w', 'b'}; fwrite(c01wb, 4, 1, fo); int h=channal*zarate*bitper/8; fwrite(&h,4,1,fo); azj = azj + 8; fwrite(&maf[ap],h, 1, fo); //寫(xiě)audio數(shù)據(jù) ap = ap +h; azj = azj +h; } //---------------------------------------------- typedef struct file File; File ffile = { { //riff {'R', 'I', 'F', 'F'}, vzj + azj + 8, {'A', 'V', 'I', ' '}, //hdrl { {'L', 'I', 'S', 'T'}, sizeof(head.ri.hd) - 8, {'s', 't', 'r', 'l'}, //avih { {'a', 'v', 'i', 'h'}, sizeof(head.ri.hd.av) - 8, 1000000/zvrate, zwidth*zheigth*vbitper*zvrate, 0, 0, nframe,0, 2, //audio + video 流總數(shù) zwidth*zheigth*vbitper, zwidth,zheigth, {0, 0, 0, 0} }, //strl1 { {'L', 'I', 'S', 'T'}, sizeof(head.ri.hd.sl1) - 8, {'s', 't', 'r', 'l'}, { //strh1 {'s', 't', 'r', 'h'}, sizeof(head.ri.hd.sl1.sh1) - 8, {'v', 'i', 'd', 's'}, //代表視頻 {'M', 'J', 'P', 'G'}, //圖像格式 0, 0, 0, 0, 1,zvrate, 0, nframe, zwidth*zheigth*vbitper*zvrate, 10000, 0, 0, 0,zwidth,zheigth }, { //strf1 {'s', 't', 'r', 'f'}, sizeof(head.ri.hd.sl1.sf1) - 8, sizeof(head.ri.hd.sl1.sf1) - 8, zwidth,zheigth, 1, vbitper, {'M', 'J', 'P', 'G'}, //圖像格式 zwidth*zheigth*vbitper/8, 0, 0, 0, 0 } }, //strl2 { {'L', 'I', 'S', 'T'}, sizeof(head.ri.hd.sl2) - 8, {'s', 't', 'r', 'l'}, { //strh2 {'s', 't', 'r', 'h'}, sizeof(head.ri.hd.sl2.sh2) - 8, {'a', 'u', 'd', 's'}, //代表聲音 {0, 0, 0, 0}, 0, 0, 0, 0, 1,zarate, //這個(gè)幀率會(huì)影響圖像的幀率 0, 0,channal*zarate*bitper/8, 10000, zarate, 0, 0, 0, 0 }, { //strf2 {'s', 't', 'r', 'f'}, sizeof(head.ri.hd.sl2.sf2) - 8, 1,channal,zarate,zarate*channal*bitper/8,channal*bitper/8,bitper, 0 } } }, //movi { {'L', 'I', 'S', 'T'}, // movisize, vzj, {'m', 'o', 'v', 'i'} } } }; fseek(fo, 0, SEEK_SET); fwrite(&ffile, sizeof(ffile), 1, fo); //----------------------------------------- fclose(fo); puts("over"); return 0; }
附 查看avi文件參數(shù):
#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){ struct file{ struct riff{ char id[4]; unsigned int size; char type[4]; struct hdrl{ char id[4]; unsigned int size; unsigned char type[4]; struct avih{ unsigned char id[4]; //塊ID,固定為avih unsigned int size; //塊大小,等于struct avi_avih_chunk去掉id和size的大小 unsigned int us_per_frame; //視頻幀間隔時(shí)間(以微秒為單位) unsigned int max_bytes_per_sec; //AVI文件的最大數(shù)據(jù)率 unsigned int padding; //設(shè)為0即可 unsigned int flags; //AVI文件全局屬性,如是否含有索引塊、音視頻數(shù)據(jù)是否交叉存儲(chǔ)等 unsigned int total_frames; //總幀數(shù) unsigned int init_frames; //為交互格式指定初始幀數(shù)(非交互格式應(yīng)該指定為0) unsigned int streams; //文件包含的流的個(gè)數(shù),僅有視頻流時(shí)為1 unsigned int suggest_buff_size; //指定讀取本文件建議使用的緩沖區(qū)大小,通常為存儲(chǔ)一楨圖像 unsigned int width; //視頻主窗口寬度(單位:像素) unsigned int height; //視頻主窗口高度(單位:像素) unsigned int reserved[4]; //保留段,設(shè)為0即可 }av; struct strl{ unsigned char id[4]; //塊ID,固定為L(zhǎng)IST unsigned int size; //塊大小,等于struct avi_strl_list去掉id和size的大小 unsigned char type[4]; //strl struct strh1{ unsigned char id[4]; //塊ID,固定為strh unsigned int size; //塊大小,等于struct avi_strh_chunk去掉id和size的大小 unsigned char stream_type[4]; //流的類型,vids表示視頻流,auds表示音頻流 unsigned char codec[4]; //指定處理這個(gè)流需要的解碼器,如JPEG unsigned int flags; //標(biāo)記,如是否允許這個(gè)流輸出、調(diào)色板是否變化等,一般設(shè)為0即可 unsigned short priority; //流的優(yōu)先級(jí),視頻流設(shè)為0即可 unsigned short language; //音頻語(yǔ)言代號(hào),視頻流設(shè)為0即可 unsigned int init_frames; //為交互格式指定初始幀數(shù)(非交互格式應(yīng)該指定為0) unsigned int scale; // unsigned int rate; //對(duì)于視頻流,rate / scale = 幀率fps unsigned int start; //對(duì)于視頻流,設(shè)為0即可 unsigned int length; //對(duì)于視頻流,length即總幀數(shù) unsigned int suggest_buff_size; //讀取這個(gè)流數(shù)據(jù)建議使用的緩沖區(qū)大小 unsigned int quality; //流數(shù)據(jù)的質(zhì)量指標(biāo) unsigned int sample_size; //音頻采樣大小,視頻流設(shè)為0即可 short left; //這個(gè)流在視頻主窗口中的顯示位置,設(shè)為{0,0,width,height}即可 short top; short right; short bottom; }sh1; struct strf1{ unsigned char id[4]; //塊ID,固定為strf unsigned int size; //塊大小,等于struct avi_strf_chunk去掉id和size的大小 //_BITMAPINFOHEADER 結(jié)構(gòu) int size1; // 指定結(jié)構(gòu)所需的字節(jié)數(shù)。=size unsigned int width; //指定位圖的寬度(以像素為單位)。 unsigned int height; //指定位圖的高度(以像素為單位) unsigned short planes; //指定目標(biāo)設(shè)備的平面數(shù)。 此值必須設(shè)置為 1。 unsigned short bitcount; //每個(gè)像素占的位數(shù),只能是1、4、8、16、24和32中的一個(gè) unsigned char compression[4]; //指定壓縮的自下而上位圖的壓縮類型 unsigned int image_size; //指定圖像的大?。ㄒ宰止?jié)為單位),等于width * height * bitcount / 8 unsigned int x_pixels_per_meter; //顯示設(shè)備的水平分辨率,設(shè)為0即可 unsigned int y_pixels_per_meter; //顯示設(shè)備的垂直分辨率,設(shè)為0即可 unsigned int num_colors; //含義不清楚,設(shè)為0即可 unsigned int imp_colors; //含義不清楚,設(shè)為0即可 }sf1; }sl1; struct strl2{ unsigned char id[4]; //塊ID,固定為L(zhǎng)IST unsigned int size; //塊大小,等于struct avi_strl_list去掉id和size的大小 unsigned char type[4]; //strl struct strh2{ unsigned char id[4]; //塊ID,固定為strh unsigned int size; //塊大小,等于struct avi_strh_chunk去掉id和size的???小 unsigned char stream_type[4]; //流的類型,vids表示視頻流,auds表示音頻流 unsigned char codec[4]; //指定處理這個(gè)流需要的解碼器,如JPEG unsigned int flags; //標(biāo)記,如是否允許這個(gè)流輸出、調(diào)色板是否變化等,一般設(shè)為0即可 unsigned short priority; //流的優(yōu)先級(jí),視頻流設(shè)為0即可 unsigned short language; //音頻語(yǔ)言代號(hào),視頻流設(shè)為0即可 unsigned int init_frames; //為交互格式指定初始幀數(shù)(非交互格式應(yīng)該指定為0) unsigned int scale; // unsigned int rate; //對(duì)于視頻流,rate / scale = 幀率fps unsigned int start; //對(duì)于視頻流,設(shè)為0即可 unsigned int length; //對(duì)于視頻流,length即總幀數(shù) unsigned int suggest_buff_size; //讀取這個(gè)流數(shù)據(jù)建議使用的緩沖區(qū)大小 unsigned int quality; //流數(shù)據(jù)的質(zhì)量指標(biāo) unsigned int sample_size; //音頻采樣大小,視頻流設(shè)為0即可 short left; //這個(gè)流在視頻主窗口中的顯示位置,設(shè)為{0,0,width,height}即可 short top; short right; short bottom; }sh2; struct strf2{ char id[4]; //strf int size; short wFormatTag; //波形音頻格式類型,格式標(biāo)記在 Microsoft Corporation 中注冊(cè),用于許多壓縮算法, short nChannels; //聲道數(shù) 85= WAVE_FORMAT_PCM int nSamplesPerSec; //采樣率,以每秒樣本數(shù) (赫) ,常見(jiàn)值為 8.0 kHz、11.025 kHz、22.05 kHz 和 44.1 kHz int nAvgBytesPerSec; //格式標(biāo)記所需的平均數(shù)據(jù)傳輸速率(以字節(jié)/秒為單位)=nsam*nblock short nBlockAlign; //阻止對(duì)齊(以字節(jié)為單位),nBlockAlign 必須等于 nChannels 和 wBitsPerSample 的乘積除以 8 (位/字節(jié)) short wBitsPerSample;// 如果 wFormatTag WAVE_FORMAT_PCM,則 wBitsPerSample 應(yīng)等于 8 或 16 short biSize; //追加到 WAVEFORMATEX 結(jié)構(gòu)末尾的額外格式信息的大?。ㄒ宰止?jié)為單位) }sf2; }sl2; }hd; struct movi{ char id[4]; unsigned int size; char type[4]; }mo; }ri; }head; FILE *f=fopen("/home/wzpc/Videos/2vuy.avi","rb"); if(f==NULL){ puts("file in error"); exit(-1); } fseek(f,0,SEEK_END); int len=ftell(f); fseek(f,0,SEEK_SET); int fd=fileno(f); char *m=mmap(NULL,len,PROT_READ,MAP_SHARED,fd,0); memcpy(&head,&m[0],sizeof(head)); //avih printf("-----------avih--------------\n"); printf("avih_id: %s\n",head.ri.hd.av.id); printf("size: %d\n",head.ri.hd.av.size); printf("us_per_frame: %d\n",head.ri.hd.av.us_per_frame); printf("max_bytes_per_sec: %d\n",head.ri.hd.av.max_bytes_per_sec); printf("paddind: %d\n",head.ri.hd.av.padding); printf("flags: %d\n",head.ri.hd.av.flags); printf("total_frames: %d\n",head.ri.hd.av.total_frames); printf("init_frame: %d\n",head.ri.hd.av.init_frames); printf("stream: %d\n",head.ri.hd.av.streams); printf("suggest_buff_size: %d\n",head.ri.hd.av.suggest_buff_size); printf("width: %d\n",head.ri.hd.av.width); printf("height: %d\n",head.ri.hd.av.height); //strh printf("-----------video strh--------------\n"); printf("strh_id: %s\n",head.ri.hd.sl1.sh1.id); printf("size: %d\n",head.ri.hd.sl1.sh1.size); printf("stream_type: %s\n",head.ri.hd.sl1.sh1.stream_type); printf("codes: %s\n",head.ri.hd.sl1.sh1.codec); printf("flags: %d\n",head.ri.hd.sl1.sh1.flags); printf("priority: %d\n",head.ri.hd.sl1.sh1.priority); printf("language: %d\n",head.ri.hd.sl1.sh1.language); printf("init_frame: %d\n",head.ri.hd.sl1.sh1.init_frames); printf("scale: %d\n",head.ri.hd.sl1.sh1.scale); printf("rate: %d\n",head.ri.hd.sl1.sh1.rate); printf("start: %d\n",head.ri.hd.sl1.sh1.start); printf("length: %d\n",head.ri.hd.sl1.sh1.length); printf("suggest_buff_size: %d\n",head.ri.hd.sl1.sh1.suggest_buff_size); printf("quality: %d\n",head.ri.hd.sl1.sh1.quality); printf("sample_size: %d\n",head.ri.hd.sl1.sh1.sample_size); printf("-----------audio strh--------------\n"); printf("ausio strh_id: %s\n",head.ri.hd.sl2.sh2.id); printf("size: %d\n",head.ri.hd.sl2.sh2.size); printf("stream_type: %s\n",head.ri.hd.sl2.sh2.stream_type); printf("codes: %s\n",head.ri.hd.sl2.sh2.codec); printf("flags: %d\n",head.ri.hd.sl2.sh2.flags); printf("priority: %d\n",head.ri.hd.sl2.sh2.priority); printf("language: %d\n",head.ri.hd.sl2.sh2.language); printf("init_frame: %d\n",head.ri.hd.sl2.sh2.init_frames); printf("scale: %d\n",head.ri.hd.sl2.sh2.scale); printf("rate: %d\n",head.ri.hd.sl2.sh2.rate); printf("start: %d\n",head.ri.hd.sl2.sh2.start); printf("length: %d\n",head.ri.hd.sl2.sh2.length); printf("suggest_buff_size: %d\n",head.ri.hd.sl2.sh2.suggest_buff_size); printf("quality: %d\n",head.ri.hd.sl2.sh2.quality); printf("sample_size: %d\n",head.ri.hd.sl2.sh2.sample_size); printf("-----------audio strf--------------\n"); printf("audio strf:id %s\n",head.ri.hd.sl2.sf2.id); printf("size: %d\n",head.ri.hd.sl2.sf2.size); printf("波型格式 : %d\n",head.ri.hd.sl2.sf2.wFormatTag); printf("nChannls: %d\n",head.ri.hd.sl2.sf2.nChannels); printf("采樣率 : %d\n",head.ri.hd.sl2.sf2.nSamplesPerSec); printf("平均數(shù)率: %d\n",head.ri.hd.sl2.sf2.nAvgBytesPerSec); printf("nMlockAlign: %d\n",head.ri.hd.sl2.sf2.nBlockAlign); printf("采樣位寬: %d\n",head.ri.hd.sl2.sf2.wBitsPerSample); printf("biSize: %d\n",head.ri.hd.sl2.sf2.biSize); return 0; }
以上就是C語(yǔ)言實(shí)現(xiàn)為無(wú)聲avi視頻添加wave音樂(lè)的詳細(xì)內(nèi)容,更多關(guān)于C語(yǔ)言視頻添加音樂(lè)的資料請(qǐng)關(guān)注腳本之家其它相關(guān)文章!
相關(guān)文章
NDK 數(shù)據(jù)結(jié)構(gòu)之隊(duì)列與棧等的實(shí)現(xiàn)
這篇文章主要介紹了NDK 數(shù)據(jù)結(jié)構(gòu)之隊(duì)列與棧等的實(shí)現(xiàn)的相關(guān)資料,希望通過(guò)本文大家能理解掌握這部分內(nèi)容,需要的朋友可以參考下2017-10-10C/C++ 中const關(guān)鍵字的用法小結(jié)
C++中的const關(guān)鍵字的用法非常靈活,而使用const將大大改善程序的健壯性。這篇文章主要介紹了C/C++ 中const關(guān)鍵字的用法,需要的朋友可以參考下2020-02-02C++ WideCharToMultiByte()函數(shù)案例詳解
這篇文章主要介紹了C++ WideCharToMultiByte()函數(shù)案例詳解,本篇文章通過(guò)簡(jiǎn)要的案例,講解了該項(xiàng)技術(shù)的了解與使用,以下就是詳細(xì)內(nèi)容,需要的朋友可以參考下2021-08-08C++?QT實(shí)現(xiàn)獲取本機(jī)網(wǎng)卡信息
這篇文章主要為大家詳細(xì)介紹了如何利用qt自帶的QNetworkInterface接口以及c++Iphlpapi庫(kù),獲取當(dāng)前windows電腦下的網(wǎng)卡信息,需要的可以參考下2024-01-01