资源简介
实现获取pc上接入的音频输入设备,并采集音频输入设备音频数据(pcm),然后基于libfaac进行编码,最终生成aac文件。
代码片段和文件信息
/*
功能描述: 简单实现用DirectShow采集Windows麦克风音频PCM数据
经过FAAC编码成AAC存储文件,可根据项目修改成直播,对讲
等实时传输类应用。
From: http://blog.csdn.net/xiejiashu
Site: http://www.easydarwin.org
时间: 2014/07/28
*/
#include “../DSAudio/General.h“
#include
#include
#include
#include
#include “../DSAudio/dscapture.h“
#include “DSAudio/FAACEncoder.h“
unsigned char fBitsPerSample fNumChannels;
unsigned fSamplingFrequency;
unsigned fGranularityInMS;
DSCapture* ds_capture_;
FAACEncoder* faac_encoder_;
unsigned long max_out_bytes;
unsigned char* outbuf;
FILE* f_aac_;
int main()
{
fBitsPerSample = 16; //单个采样音频信息位数
fNumChannels = 2; //通道数
fSamplingFrequency = 44100;//采样率
faac_encoder_ = new FAACEncoder(); //新建AAC编码对象
faac_encoder_->Init(fSamplingFrequencyfNumChannelsfBitsPerSample); //初始化AAC编码器
ds_capture_ = new DSCapture();
std::map a_devices = ds_capture_->DShowGraph()->AudioCapDevices();
if(a_devices.size() == 0 ) ::exit(0);
DSAudioFormat audio_fmt;
audio_fmt.samples_per_sec = fSamplingFrequency;
audio_fmt.channels = fNumChannels;
audio_fmt.bits_per_sample = fBitsPerSample;
// 枚举音频采样设备,选择最后一个
CString audio_device_id;
for (std::map::iterator it = a_devices.begin(); it != a_devices.end(); ++it)
{
audio_device_id = it->first;
}
ds_capture_->Create(audio_device_id audio_fmt NULL);
// 开始采集音频数据
ds_capture_->StartAudio();
::Sleep(10);
max_out_bytes = faac_encoder_->MaxOutBytes();
outbuf = (unsigned char*)malloc(max_out_bytes);
// 编码后存文件
f_aac_ = fopen(“./audio.aac““wb“);
printf(“Recording...“);
while(1)
{
int pcmLen = 0;
// 采集音频pcm数据
char* pcmBuf = ds_capture_->GetBuffer(pcmLen);
if(pcmLen > 0)
{
unsigned int sample_count = (pcmLen << 3)/fBitsPerSample;
unsigned int buf_size = 0;
// 编码AAC
faac_encoder_->Encode((unsigned char*)pcmBuf sample_count (unsigned char*)outbuf buf_size);
if(buf_size > 0)
{
printf(“.“);
// 存文件或者自定义
fwrite(outbuf1buf_sizef_aac_);
}
}
// 释放采集的pcm数据
ds_capture_->ReleaseBuffer(pcmBuf);
::Sleep(1);
}
free(outbuf);
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 887 2013-09-22 17:35 WinAudioRecord\AudioRecord.sln
文件 5769 2013-09-23 15:10 WinAudioRecord\AudioRecord.vcproj
文件 131072 2013-07-21 22:50 WinAudioRecord\Debug\libfaacd.dll
文件 631 2013-07-21 22:54 WinAudioRecord\DirectShow\Include\activecf.h
文件 1826 2013-07-21 22:54 WinAudioRecord\DirectShow\Include\amaudio.h
文件 1065 2013-07-21 22:54 WinAudioRecord\DirectShow\Include\amparse.h
文件 73261 2013-07-21 22:54 WinAudioRecord\DirectShow\Include\amstream.h
文件 3974 2013-07-21 22:54 WinAudioRecord\DirectShow\Include\amva.h
文件 19851 2013-07-21 22:54 WinAudioRecord\DirectShow\Include\Amvideo.h
文件 1097 2013-07-21 22:54 WinAudioRecord\DirectShow\Include\atsmedia.h
文件 1532 2013-07-21 22:54 WinAudioRecord\DirectShow\Include\audevcod.h
文件 20543 2013-07-21 22:54 WinAudioRecord\DirectShow\Include\austream.h
文件 13805 2013-07-21 22:54 WinAudioRecord\DirectShow\Include\aviriff.h
文件 6861 2013-07-21 22:54 WinAudioRecord\DirectShow\Include\ba
文件 125594 2013-07-21 22:54 WinAudioRecord\DirectShow\Include\bdaiface.h
文件 54539 2013-07-21 22:54 WinAudioRecord\DirectShow\Include\bdamedia.h
文件 53527 2013-07-21 22:54 WinAudioRecord\DirectShow\Include\Bdatif.h
文件 15486 2013-07-21 22:54 WinAudioRecord\DirectShow\Include\bdatypes.h
文件 944 2013-07-21 22:54 WinAudioRecord\DirectShow\Include\comlite.h
文件 178266 2013-07-21 22:54 WinAudioRecord\DirectShow\Include\control.h
文件 88071 2013-07-21 22:54 WinAudioRecord\DirectShow\Include\d3d.h
文件 72232 2013-07-21 22:54 WinAudioRecord\DirectShow\Include\d3d8.h
文件 16088 2013-07-21 22:54 WinAudioRecord\DirectShow\Include\d3d8caps.h
文件 63735 2013-07-21 22:54 WinAudioRecord\DirectShow\Include\d3d8types.h
文件 96132 2013-07-21 22:54 WinAudioRecord\DirectShow\Include\d3d9.h
文件 22164 2013-07-21 22:54 WinAudioRecord\DirectShow\Include\d3d9caps.h
文件 69800 2013-07-21 22:54 WinAudioRecord\DirectShow\Include\d3d9types.h
文件 26113 2013-07-21 22:54 WinAudioRecord\DirectShow\Include\d3dcaps.h
文件 14874 2013-07-21 22:54 WinAudioRecord\DirectShow\Include\d3drm.h
文件 24261 2013-07-21 22:54 WinAudioRecord\DirectShow\Include\d3drmdef.h
............此处省略202个文件信息
- 上一篇:车型识别系统vc源码opencv
- 下一篇:屏幕融合软件源码
相关资源
- PCM编码实验系统的设计和实现
- 实验1:PCM5102播放SD卡音乐STM32F103ZET
- Verilog编写的采集PCM1750串行输出的代码
- PCM格式音乐文件音频文件
- pcm格式文件资源集合
- pcm音频文件
- 语音信号频带传输通信系统仿真——
- ICAO ANEX15 icao 附件15
- FFmpeg解码MP4分别播放YUV视频和PCM音频
- H264_AAC_TS_MUX_本地文件_1
- H264_AAC_FLV_MUX_本地文件_1
- Nokia PCM 培训教程
- 海思3516CV300平台音频编解码库
- JR 9X清晰版中文说明书(PCM版)
- espcms_utf8_v5.8.14.02.12
- g711g726adpcm编解码,有demo和声音文件,
- g711音频文件测试用
- CAACATIA二次开发入门宝典
- wav_pcm.zip
- PCM音频采集与播放
- Serial IO Card-华塑PCMCIA转串口RS232-ox
- cvsd pcm 编解码算法实现
- aac+h264封装MP4
- pcm/fm正交调制
- faac windows
- 国际民用航空公约附件十中文官方翻
- pcm格式音频
- Handbook of Medical Imaging Processing and Ana
- FlashMediaLiveEncoder3.2_with_AAC(key)
- Quantum Computation and Quantum - MICHAEL NIEL
评论
共有 条评论