问题描述
我正在使用Directshow开发视频捕获应用程序,并使用Microsoft MPEG-2 Encoder将捕获的视频保存在Mpeg-2中.我的应用程序如下所示:
Decklink视频捕获->
Microsoft MPEG-2编码器->文件编写器(.mpg)
Decklink音频捕获->
一切正常都可以使用编码器的默认设置,但是我想更改一些设置,例如:视频比特率,音频采样率等
我已经从MSDN阅读了有关MS MPEG-2编码器的全部信息:
http://msdn.microsoft.com/zh-CN/library/dd390678(v=VS.85).aspx,
并且我知道这些设置都可以在< b> ICodecAPI</b>中进行调整.界面,但我需要帮助,因为我不确定如何使用< b> ICodecAPI</b>在我的代码中.
有人可以帮我提供示例或示例代码的方法吗?
预先谢谢您.
Hi,
I am developing a video capture application using Directshow and saving the captured video in Mpeg-2 using Microsoft MPEG-2 Encoder.My application looks like this:
Decklink Video Capture ->
Microsoft MPEG-2 Encoder -> File Writer(.mpg)
Decklink Audio Capture ->
Everything works fine with encoder''s default settings.But I want to change some settings e.g. : video bit rate, audio sample rate, etc.
I''ve read all about MS MPEG-2 Encoder from MSDN :
http://msdn.microsoft.com/en-us/library/dd390678(v=VS.85).aspx,
and I know that these settings can all be adjusted in <b>ICodecAPI</b> interface,but I need help because I''m not sure how to use the <b>ICodecAPI</b> in my code.
Can anyone help me with example or sample code how to do that?
Thank you in advance.
推荐答案
if (m_pMpeg2Muxer)
{
ICodecAPI * pCodecAPI;
if (SUCCEEDED(m_pMpeg2Muxer->QueryInterface(IID_ICodecAPI,(void**)&pCodecAPI)))
{
_variant_t _value;
if (m_lVideoBitrate > 0)
{
_value = m_lVideoBitrate;
if (FAILED(pCodecAPI->SetValue(&CODECAPI_AVEncCommonMeanBitRate,&_value)))
{
m_lVideoBitrate = 0;
}
}
if (m_lVideoBitrate <= 0)
{
if (SUCCEEDED(pCodecAPI->GetDefaultValue(&CODECAPI_AVEncCommonMeanBitRate,&_value)))
{
m_lVideoBitrate = _value;
pCodecAPI->SetValue(&CODECAPI_AVEncCommonMeanBitRate,&_value);
}
}
pCodecAPI->Release();
}
}
return NOERROR;
建议:如果要处理编码的所有属性,请不要使用Microsoft Mpeg-2.
问候,
音速.
Suggestions: not use the Microsoft Mpeg-2 stuff if you want to handle the all properties of encoding.
Regards,
Sonic.
这篇关于有关Microsoft MPEG-2编码器的帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!