有关Microsoft MPEG-2编码器的帮助 [英] Help with Microsoft MPEG-2 encoder

查看:71
本文介绍了有关Microsoft MPEG-2编码器的帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我正在使用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.

推荐答案

阅读这些文档,这似乎是QI''为ICodecAPI的mpeg2编码器接口然后使用该接口的简单情况.接口?

使用AVAudioSampleRate指南访问音频采样率,使用AVEncCommonMaxBitRateAVEncCommonMeanBitRate
访问视频比特率.
还是我误解了您的问题?
Reading those docs, it looks to be a simple case of QI''ing the mpeg2 encoder interface for ICodecAPI and then using that interface?

The audio sample rate is accessed using the AVAudioSampleRate guid and the video bitrate with AVEncCommonMaxBitRate and AVEncCommonMeanBitRate

or, have I misunderstood your question?


我从事多媒体工作多年了.

Microsoft有2种对mpeg-2进行编码的方法,一种是使用单独的视频和音频编码器(也由Microsoft提供),并且将Muxer与嵌入式音频和视频编码器结合使用.
这里是问题:

微软mpeg-2视频编码器(与我检查音频时出现的问题相同):
-比特率更改不可用,我实际上尝试修改最常用的选项-不走运.
-时间戳记已损坏-如果您使用捕获设备或其他来源的编码来处理此ecoder的发送时间,则可以正常工作-否则,请不要怀疑它们(它们产生的时间戳仅是dts而不是pts),即使您使用自己的多路复用器系统,您将遇到很多问题.

嵌入了muxing的Mpeg-2编码器.
适用于音频和视频输入.
-问题在于它可以提供NULL作为格式块-您的输出过滤器应注意这一点.
-一旦我需要处理h.264解码并编码为mpeg-2,它就可以使用Microsoft DTV Video Decoder过滤器对视频进行解码(注意:此过滤器也不是很好-原因很多)-实际上一些解码器未处理NULL格式.

配置编码器-适用于m-不走运.
您可以尝试的方法示例:

I working with multimedia for a lot of years.

There are 2 microsoft ways to encode mpeg-2 one is using the separate video and audio encoders (also provided by Microsoft) and usage of Muxer with embedded audio and video encoders.
Here is the issues:

The microsoft mpeg-2 video encoder (same issues as I checked with audio):
- the bitrate changes not available I actually try to modify most common options - no luck.
- timestamps are broken - if you use the encoding from capture device or other source who handle the delivering timing this ecoders are works - otherwise forget abt them (the time stamp they produce is the dts only and not pts) even if you use your own muxer system you will get a lot''s of issues with that.

The Mpeg-2 encoder with muxing embedded.
Works properly for audio and video input.
- the issue is that it can provide NULL as format block - your output filter should takes care of that.
- once I need to handle decoding h.264 and encode into mpeg-2 it works proper mostly with usage of Microsoft DTV Video Decoder filter for decoding video (Note: this filter is also not good - lot''s of reasons) - actually some decoders were not handled NULL format.

Configuring encoder - for m - no luck.
Example the way you can try to :

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编码器的帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆