如何改进我的代码以提高视频质量?

时间:2021-07-05 14:58:24

I am using the following code to leverage Windows Media Encoder to record screen. I am using Windows Vista, screen resolution 1024 × 768, 32-bit. My issue is, the video could be recorded successfully, but when I playback the recorded video, the quality of video is not very good -- e.g. characters are very obscure. I am wondering what are the parameters I should try to tune to get better quality of recorder video?

我使用以下代码来利用Windows Media Encoder来记录屏幕。我使用的是Windows Vista,屏幕分辨率为1024×768,32位。我的问题是,视频可以成功录制,但是当我播放录制的视频时,视频质量不是很好 - 例如人物非常模糊。我想知道我应该尝试调整哪些参数以获得更好的录像机视频质量?

My code,

            static WMEncoder encoder = new WMEncoder();

            IWMEncSourceGroup SrcGrp;
            IWMEncSourceGroupCollection SrcGrpColl;
            SrcGrpColl = encoder.SourceGroupCollection;
            SrcGrp = (IWMEncSourceGroup)SrcGrpColl.Add("SG_1");

            IWMEncVideoSource2 SrcVid;
            SrcVid = (IWMEncVideoSource2)SrcGrp.AddSource(WMENC_SOURCE_TYPE.WMENC_VIDEO);
            SrcVid.SetInput("ScreenCap://ScreenCapture1", "", "");
            IWMEncFile File = encoder.File;
            File.LocalFileName = "C:\\OutputFile.avi";

            // Choose a profile from the collection.
            IWMEncProfileCollection ProColl = encoder.ProfileCollection;
            IWMEncProfile Pro;
            for (int i = 0; i < ProColl.Count; i++)
            {
                Pro = ProColl.Item(i);
                if (Pro.Name == "Windows Media Video 8 for Local Area Network (384 Kbps)")
                {
                    SrcGrp.set_Profile(Pro);
                    break;
                }
            }

        encoder.Start();

thanks in advance, George

乔治,提前谢谢

1 个解决方案

#1


Video encoders use a certain kbit/second ratio to limit the size of the generated stream. The fewer kbits/sec the less detail you will get due to fewer coefficients from the DCT and bigger quantization values. In other words: the more kbits/sec you put into the video the more detail can be stored in the stream by the encoder.

视频编码器使用某个kbit /秒比率来限制生成的流的大小。由于来自DCT的系数越少,量化值越大,得到的细节越少,kbits / sec越少。换句话说:您放入视频的kbits / sec越多,编码器就可以在流中存储更多细节。

Judging by your code you have chosen a profile which uses 384 kbit/s which is not very much for a 1024*768 video. You should try other profiles or set bitrate you want yourself.

根据您的代码判断,您选择了一个使用384 kbit / s的配置文件,这对于1024 * 768视频来说并不是很大。您应该尝试其他配置文件或设置您想要的比特率。

#1


Video encoders use a certain kbit/second ratio to limit the size of the generated stream. The fewer kbits/sec the less detail you will get due to fewer coefficients from the DCT and bigger quantization values. In other words: the more kbits/sec you put into the video the more detail can be stored in the stream by the encoder.

视频编码器使用某个kbit /秒比率来限制生成的流的大小。由于来自DCT的系数越少,量化值越大,得到的细节越少,kbits / sec越少。换句话说:您放入视频的kbits / sec越多,编码器就可以在流中存储更多细节。

Judging by your code you have chosen a profile which uses 384 kbit/s which is not very much for a 1024*768 video. You should try other profiles or set bitrate you want yourself.

根据您的代码判断,您选择了一个使用384 kbit / s的配置文件,这对于1024 * 768视频来说并不是很大。您应该尝试其他配置文件或设置您想要的比特率。