日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

PJMEDIA之录音器的使用(capture sound to avi file)

發布時間:2023/12/2 编程问答 46 豆豆
生活随笔 收集整理的這篇文章主要介紹了 PJMEDIA之录音器的使用(capture sound to avi file) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

為了熟悉pjmedia的相關函數以及使用方法,這里練習了官網上的一個錄音器的例子。

核心函數:

pj_status_t pjmedia_wav_writer_port_create(pj_pool_t *?pool,
??const char *?filename,
??unsigned?clock_rate,
??unsigned?channel_count,
??unsigned?samples_per_frame,
??unsigned?bits_per_sample,
??unsigned?flags,
??pj_ssize_t?buff_size,
??pjmedia_port **?p_port?
?)??

Create a media port to record streams to a WAV file. Note that the port must be closed properly (with pjmedia_port_destroy()) so that the WAV header can be filled with correct values (such as the file length). WAV writer port supports for writing audio in uncompressed 16 bit PCM format or compressed G.711 U-law/A-law format, this needs to be specified in flags param.

Parameters
poolPool to create memory buffers for this port.
filenameFile name.
clock_rateThe sampling rate.
channel_countNumber of channels.
samples_per_frameNumber of samples per frame.
bits_per_sampleNumber of bits per sample (eg 16).
flagsPort creation flags, see pjmedia_file_writer_option.
buff_sizeBuffer size to be allocated. If the value is zero or negative, the port will use default buffer size (which is about 4KB).
p_portPointer to receive the file port instance.
Returns
PJ_SUCCESS on success.
pj_status_t pjmedia_snd_port_create_rec(pj_pool_t *?pool,
??int?index,
??unsigned?clock_rate,
??unsigned?channel_count,
??unsigned?samples_per_frame,
??unsigned?bits_per_sample,
??unsigned?options,
??pjmedia_snd_port **?p_port?
?)??

Create unidirectional sound device port for capturing audio streams from the sound device with the specified parameters.

Parameters
poolPool to allocate sound port structure.
indexDevice index, or -1 to let the library choose the first available device.
clock_rateSound device's clock rate to set.
channel_countSet number of channels, 1 for mono, or 2 for stereo. The channel count determines the format of the frame.
samples_per_frameNumber of samples per frame.
bits_per_sampleSet the number of bits per sample. The normal value for this parameter is 16 bits per sample.
optionsOptions flag.
p_portPointer to receive the sound device port instance.
Returns
PJ_SUCCESS on success, or the appropriate error code.
pj_status_t pjmedia_endpt_create(pj_pool_factory *?pf,
??pj_ioqueue_t *?ioqueue,
??unsigned?worker_cnt,
??pjmedia_endpt **?p_endpt?
?)??

Create an instance of media endpoint.

Parameters
pfPool factory, which will be used by the media endpoint throughout its lifetime.
ioqueueOptional ioqueue instance to be registered to the endpoint. The ioqueue instance is used to poll all RTP and RTCP sockets. If this argument is NULL, the endpoint will create an internal ioqueue instance.
worker_cntSpecify the number of worker threads to be created to poll the ioqueue.
p_endptPointer to receive the endpoint instance.
Returns
PJ_SUCCESS on success.
pj_status_t pjmedia_snd_port_connect(pjmedia_snd_port *?snd_port,
??pjmedia_port *?port?
?)??

Connect a port to the sound device port. If the sound device port has a sound recorder device, then this will start periodic function call to the port's put_frame() function. If the sound device has a sound player device, then this will start periodic function call to the port's get_frame() function.

For this version of PJMEDIA, the media port MUST have the same audio settings as the sound device port, or otherwise the connection will fail. This means the port MUST have the same clock_rate, channel count, samples per frame, and bits per sample as the sound device port.

Parameters
snd_portThe sound device port.
portThe media port to be connected.
Returns
PJ_SUCCESS on success, or the appropriate error code.
//capture sound to wav file //heat nan -test #include<pjmedia.h> #include<pjlib.h> #include<stdio.h> #include<stdlib.h>#define CLOCK_RATE 44100 //采樣率 #define NCHANNELS 2 //通道數 #define SAMPLES_PER_FRAME (NCHANNELS *(CLOCK_RATE*10/1000)) //每幀包含的采樣數 #define BITS_PER_SAMPLE 16 //每個抽樣的字節數int main() {pj_caching_pool cp;pjmedia_endpt *med_endpt;pj_pool_t *pool;pjmedia_port *file_port; pjmedia_snd_port *snd_port;pj_status_t status;char tmp[10];char filename[20];status=pj_init();if(status!=PJ_SUCCESS){PJ_LOG(3,("failed","pj_init"));}pj_caching_pool_init(&cp,&pj_pool_factory_default_policy,0); //創建endpointstatus=pjmedia_endpt_create(&cp.factory,NULL,1,&med_endpt);if(status!=PJ_SUCCESS){PJ_LOG(3,("failed","pjmedia_endpt_create"));}pool=pj_pool_create(&cp.factory,"wav_recoder",4000,4000,NULL); //輸入要保存錄音的文件名 PJ_LOG(3,("wav_recorder","please input the file name!"));gets(filename); //創建錄音端口 把音頻流寫成wav文件status=pjmedia_wav_writer_port_create(pool,filename,CLOCK_RATE,NCHANNELS,SAMPLES_PER_FRAME,BITS_PER_SAMPLE,0,0,&file_port //指向接收該實例的pjmedia_port);if(status!=PJ_SUCCESS){PJ_LOG(3,("failed","pjmedia_wav_write_port_create"));} //創建單向的音頻設備端口用來捕獲音頻status=pjmedia_snd_port_create_rec(pool,-1,PJMEDIA_PIA_SRATE(&file_port->info),PJMEDIA_PIA_CCNT(&file_port->info),PJMEDIA_PIA_SPF(&file_port->info),PJMEDIA_PIA_BITS(&file_port->info),0,&snd_port);if(status!=PJ_SUCCESS){PJ_LOG(3,("failed","pjmedia_snd_port_create_rec"));} //連接兩個端口開始錄音status=pjmedia_snd_port_connect(snd_port,file_port);if(status!=PJ_SUCCESS){PJ_LOG(3,("failed","pjmedia_snd_port_connect"));}pj_thread_sleep(10);//顯示終止信息 puts("PRESS <ENTER> to stop recording and quit");if(fgets(tmp,sizeof(tmp),stdin)==NULL){puts("EOF while reading stdin,will quit now..");}//養成良好習慣,吃完飯總要刷刷碗吧! pjmedia_snd_port_destroy(snd_port);pjmedia_port_destroy(file_port);pj_pool_release(pool);pjmedia_endpt_destroy(med_endpt);pj_caching_pool_destroy(&cp);pj_shutdown();return 0; // pj_thread_sleep(10);}

?

轉載于:https://www.cnblogs.com/heat-man/p/3664558.html

總結

以上是生活随笔為你收集整理的PJMEDIA之录音器的使用(capture sound to avi file)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 精品成人久久 | 亚洲最大中文字幕 | 人妻熟女一区 | 阿的白色内裤hd中文 | 亚洲国内在线 | 欧美三级理论片 | 久久久久久久 | 在线免费观看黄 | 国产极品美女在线 | 丁香色欲久久久久久综合网 | av导航在线 | 亚洲精品乱码久久久久久蜜桃欧美 | 99精品区| 91在线免费视频 | 2019中文字幕在线 | 国产第3页 | 日韩伦理在线视频 | 综合久色 | 又大又粗弄得我出好多水 | 在线亚洲天堂 | 波多野结衣一二三区 | 日韩在线观看视频网站 | 天天做夜夜做 | 打屁屁日本xxxxx变态 | 欧美 日韩 国产 在线观看 | www.三级.com | 懂色av蜜臀av粉嫩av分享 | 国产哺乳奶水91在线播放 | 日韩精品――中文字幕 | 91嫩草影视 | 好吊妞视频这里只有精品 | 日本老年老熟无码 | 欧美精选一区二区 | 国产精品美女av | 欧美搞逼视频 | 国产精品爽爽爽 | www天堂网 | 欧洲一级片 | 精品视频91 | 精品肉丝脚一区二区三区 | 三级大片在线观看 | 人人干人人干人人干 | 午夜爱爱网站 | 久久国产影视 | 黑丝国产一区 | 伊人久久免费视频 | 精品欧美激情精品一区 | 亚洲激情电影在线 | 国产www免费 | 国产亚洲制服 | 亚洲色图综合在线 | 亚洲另类天堂 | 韩国伦理片在线播放 | 国产卡一卡二卡三 | 成人午夜精品无码区 | 欧美精产国品一二三区 | 欧美日韩在线视频 | 亚洲最黄视频 | 亚洲系列在线观看 | 漂亮少妇高潮午夜精品 | 日本高清不卡在线观看 | 色视频一区二区 | 日韩免费av在线 | 欧美老熟妇喷水 | 大桥未久中文字幕 | 日韩乱码在线观看 | 国产精品69久久 | 91玉足脚交白嫩脚丫 | 亚洲视频在线免费看 | 男女爱爱福利视频 | 国产高清久久 | 特级西西人体wwwww | 国产三级影院 | 天天操天天操天天操天天 | 国产乱码精品一区二三区蜜臂 | www.av天天| 三级精品在线观看 | 理论片在线观看理伦片 | 国产精品乱码久久久久久久久 | 亚洲av无码一区二区三区网址 | 精品在线小视频 | 性做久久久久久久 | 亚洲欧美日韩精品永久在线 | 欧美69式性猛交 | 欧美在线视频一区二区三区 | 狼人色综合 | 五月天看片| 国产精品国产三级国产三级人妇 | 色狠狠一区二区三区香蕉 | 国产三区在线观看 | 日韩欧美一二区 | 欧美日韩国产在线播放 | 亚洲精品电影网 | 香蕉视频国产在线观看 | 一本色道久久88综合日韩精品 | 视频1区2区 | 视频在线观看网站免费 | 一个色综合网 | 99国产精品免费 |