how to improve my code to make better video quality?

戏子无情 提交于 2019-12-23 05:24:18

问题


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?

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:


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.

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.



来源:https://stackoverflow.com/questions/843100/how-to-improve-my-code-to-make-better-video-quality

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!