Esempio n. 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            MediaInfoDLL.MediaInfo media = new MediaInfoDLL.MediaInfo();
            //string path = @"f:\video\temp2.mkv";
            media.Open(video.Path);

            //media.Get(vobceshi.MediaInfoDLL.StreamKind.General, 0, "Duration");
            //rtbmessage.Text = media.Inform();

            //获得媒体的播放时间,单位为ms
            string d = media.Get(MediaInfoDLL.StreamKind.General, 0, "Duration");

            //TimeSpan ts = new TimeSpan((long.Parse(d))*10000);
            ShowMessage("媒体的时间长度为:" + TimeCodeString(int.Parse(d)));

            //获取文件长度(单位B)
            float fs = Convert.ToSingle(media.Get(MediaInfoDLL.StreamKind.General, 0, "FileSize"));
            ShowMessage("文件大小为:" + fs / 1024 / 1024 + "MB");

            //获得媒体格式信息
            string type = media.Get(vobceshi.MediaInfoDLL.StreamKind.General, 0, "Format");
            ShowMessage("文件容器格式为:" + type);

            //获取文件名
            string name = media.Get(MediaInfoDLL.StreamKind.General, 0, "FileName");
            string leixing = media.Get(MediaInfoDLL.StreamKind.General, 0, "FileExtension");
            ShowMessage("文件名称为:"+name+"."+leixing);

            //获取全局速率
            string overall = media.Get(MediaInfoDLL.StreamKind.General,0,"OverallBitRate");
            ShowMessage("全局速率为:"+convert(int.Parse(overall))+"Kbps");

            //视频的码率
            string videorate = media.getVidBitrate();
            ShowMessage("视频码率为:"+convert(int.Parse(videorate))+"Kbps");

            //音频的码率
            string audiorate = media.getAudioBitrate();
            ShowMessage("音频的码率为:"+convert(int.Parse(audiorate))+"Kbps");

            //视频的宽度和高度
            bool bvideo = media.Count_Get(vobceshi.MediaInfoDLL.StreamKind.Video) > 0;
            ShowMessage("是否为视频:" + bvideo);
            if (bvideo)
            {
                string width = media.getWidth();
                ShowMessage("视频的宽度为:" + width);
                string height = media.getHeight();
                ShowMessage("视频的高度为:" + height);
                video.Vwidth = width;
                video.Vheight = height;
            }

            //视频比例
            string bili = media.Get(MediaInfoDLL.StreamKind.Video, 0, "DisplayAspectRatio");
            ShowMessage("视频比例为:"+bili);

            //视频格式
            string vformat = media.Get(MediaInfoDLL.StreamKind.Video,0,"Format");
            ShowMessage("视频格式为:"+vformat);

            //音频格式
            string aformat = media.Get(MediaInfoDLL.StreamKind.Audio,0,"Format");
            ShowMessage("音频格式为:"+aformat);

            //编码格式
            string coding = media.getVidCodec();
            ShowMessage("编码格式为:"+coding);

            //帧速率
            string rate = media.getFPS();
            ShowMessage("帧速率为:"+rate+"fps");

            //音频采样率
            string srate = media.Get(MediaInfoDLL.StreamKind.Audio,0,"SamplingRate");
            ShowMessage("音频采样率为:"+srate);

            //显示所有媒体信息(第二参数的1相当于true)
            media.Option("Complete", "1");
            ShowMessage(media.Inform());

            media.Close();
        }
Esempio n. 2
0
        private void CheckInfo()
        {
            //Type = "check";
            //StartProcess();//检测
            MediaInfoDLL.MediaInfo media = new MediaInfoDLL.MediaInfo();
            media.Open(video.Path);
            //获得媒体的播放时间,单位为ms
            string d = media.Get(MediaInfoDLL.StreamKind.General, 0, "Duration");
            ShowMessage("文件的时间长度为:" + TimeCodeString(int.Parse(d)));
            video.Vtimecount = timecount(TimeCodeString(int.Parse(d))).ToString();
            //获取文件长度(单位B)
            float fs = Convert.ToSingle(media.Get(0, 0, "FileSize"));
            ShowMessage("文件长度为:" + fs / 1024 / 1024 + "B");

            //获得媒体格式信息
            string type = media.Get(vobceshi.MediaInfoDLL.StreamKind.General, 0, "Format");
            ShowMessage("文件格式为:" + type);

            //

            bool bvideo = media.Count_Get(vobceshi.MediaInfoDLL.StreamKind.Video) > 0;
            ShowMessage("是否为视频:" + bvideo);
            if (bvideo)
            {
                string width = media.getWidth();
                ShowMessage("视频的宽度为:" + width);
                string height = media.getHeight();
                ShowMessage("视频的高度为:"+height);
                video.Vwidth = width;
                video.Vheight = height;
            }

            //显示所有媒体信息(第二参数的1相当于true)
            media.Option("Complete", "1");
            ShowMessage(media.Inform());

            media.Close();
        }