关于directshow 麦克风音频采集问题

howehowe 2011-04-15 03:49:43
我根据directshow sample的创建了一个capture 出来采集麦克风的输入,直接连上renderer实时播放,但总是有1s延时,我的设置是这样的。


// Find number of bytes in one second
long lBytesPerSecond = (long) (nBytesPerSample * nFrequency * nChannels);

// Set to 50ms worth of data , DEFAULT_BUFFER_TIME = 0.05
long lBufferSize = (long) ((float) lBytesPerSecond * DEFAULT_BUFFER_TIME);

ALLOCATOR_PROPERTIES prop={0};
prop.cbBuffer = lBufferSize;
prop.cBuffers = 6;
prop.cbAlign = nBytesPerSample * nChannels;
hr = pNeg->SuggestAllocatorProperties(&prop);
...全文
254 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
伪装者1982 2011-04-27
  • 打赏
  • 举报
回复
调用声卡采集端的pin上的IID_IAMBufferNegotiation接口设置,下面设置是50ms延时

nFrequency = USE_SAMPLE_RATE;//48000;

// Find number of bytes in one second
long lBytesPerSecond = (long) (nBytesPerSample * nFrequency * nChannels);

// Set to 50ms worth of data
long lBufferSize = (long) ((float) lBytesPerSecond * 0.05);

// Get the buffer negotiation interface for each pin,
// since there could be both a Capture and a Preview pin.

// Get buffer negotiation interface
hr = pPin->QueryInterface(IID_IAMBufferNegotiation, (void **)&pNeg);
if (FAILED(hr))
{
return hr;
}
ALLOCATOR_PROPERTIES prop={0};
//hr = pNeg->GetAllocatorProperties(&prop);
// Set the buffer size based on selected settings
prop.cbBuffer = lBufferSize;
prop.cBuffers = 6;
prop.cbAlign = nBytesPerSample * nChannels;
hr = pNeg->SuggestAllocatorProperties(&prop);
SAFE_RELEASE(pNeg);
howehowe 2011-04-15
  • 打赏
  • 举报
回复
自己顶
howehowe 2011-04-15
  • 打赏
  • 举报
回复
但在winxp 将麦克风输出的音量取消静音的话或者在win7侦听麦克风,麦克风输出的声音延时是很少的,几乎没有~~用directshow怎样才可以做到这样·??或者有什么方法可以做到~?

2,543

社区成员

发帖
与我相关
我的任务
社区描述
专题开发/技术/项目 多媒体/流媒体开发
社区管理员
  • 多媒体/流媒体开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧