当前位置: 首页>>代码示例>>C#>>正文


C# MediaInfo.Open方法代码示例

本文整理汇总了C#中MediaInfoLib.MediaInfo.Open方法的典型用法代码示例。如果您正苦于以下问题:C# MediaInfo.Open方法的具体用法?C# MediaInfo.Open怎么用?C# MediaInfo.Open使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MediaInfoLib.MediaInfo的用法示例。


在下文中一共展示了MediaInfo.Open方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ExtractInfo

        public static string[] ExtractInfo(string path)
        {
            MediaInfo MI = new MediaInfo();            
            MI.Open(path); 
            string[] returnInfo = new string[5];

            //File name 0
            returnInfo[0] = MI.Get(0, 0, "FileName");

            //Size 1
            string sizeInKBStr = MI.Get(0, 0, "FileSize/String").Substring(
                0, MI.Get(0, 0, "FileSize/String").LastIndexOf(" ")).Replace(" ", "");
            double sizeInKB = Double.Parse(sizeInKBStr);
            double sizeInMB = (double)(sizeInKB / 1024);
            string sizeInMBStr = String.Format("{0:0.00}", sizeInMB); 
            returnInfo[1] = sizeInMBStr + " MB";

            //Date created 2
            returnInfo[2] = MI.Get(0, 0, "File_Created_Date").Substring(
                MI.Get(0, 0, "File_Created_Date").IndexOf(" ") + 1, MI.Get(0, 0, "File_Created_Date").LastIndexOf(".") - 4);

            //Performer 3
            returnInfo[3] = MI.Get(0, 0, "Performer");

            //Length 4
            returnInfo[4] = MI.Get(0, 0, "Duration/String3").Substring(0, MI.Get(0, 0, "Duration/String3").LastIndexOf("."));

            return returnInfo;
        }
开发者ID:angad,项目名称:PeopleBAWX,代码行数:29,代码来源:MIExtractor.cs

示例2: MediaViewModel

        public MediaViewModel(string Name = "",
            string ArtistName = "",
            string AlbumName = "",
            Uri Path = null,
            String Length = "00:00:00")
        {
            Dictionary<String, String> tmp = new Dictionary<string, string>();
            if (Path != null)
            {
                try
                {
                    MediaInfo lol = new MediaInfo();
                    if (lol.Open(Uri.UnescapeDataString(Path.AbsolutePath)) == 1)
                    {
                        foreach (string entry in lol.Inform().Split('\n'))
                        {
                            var tokens = entry.Split(':');
                            if (tokens.Length == 2)
                                tmp[tokens[0].Trim()] = tokens[1].Trim();
                        }
                        lol.Close();
                    }
                }
                catch (Exception e)
                {
                    MessageBox.Show("MediaInfo: "+ e.Message);
                }
            }

            Song = new Media(tmp.ContainsKey("Track name") ? tmp["Track name"] : "",
                            tmp.ContainsKey("Performer") ? tmp["Performer"] : "",
                            tmp.ContainsKey("Album") ? tmp["Album"] : "",
                            Path, tmp.ContainsKey("Duration") ? getLength(tmp["Duration"]) : "");
        }
开发者ID:Vyko,项目名称:MyWmp,代码行数:34,代码来源:MediaViewModel.cs

示例3: GetVideoFileTakenDate

        public static DateTime? GetVideoFileTakenDate(string filePath)
        {
            MediaInfo mediaInfo = null;
            try
            {
                mediaInfo = new MediaInfo();
                mediaInfo.Open(filePath);

                DateTime? result = null;
                string recordedDate = mediaInfo.Get(StreamKind.General, 0, "Recorded_Date");
                if (!string.IsNullOrWhiteSpace(recordedDate))
                {
                    result = DateTime.Parse(recordedDate, CultureInfo.InvariantCulture, DateTimeStyles.AssumeLocal);
                }

                if (result == null)
                {
                    recordedDate = mediaInfo.Get(StreamKind.General, 0, "Encoded_Date");
                    if (string.IsNullOrWhiteSpace(recordedDate))
                    {
                        recordedDate = mediaInfo.Get(StreamKind.General, 0, "Tagged_Date");
                    }
                    if (!string.IsNullOrWhiteSpace(recordedDate))
                    {
                        var dateTimeStyles = DateTimeStyles.AssumeUniversal;
                        // Canon records local time as UTC
                        var canonCameraIdentifier = mediaInfo.Get(StreamKind.General, 0, "CodecID/String");
                        if (canonCameraIdentifier.Contains("/CAEP"))
                        {
                            dateTimeStyles = DateTimeStyles.AssumeLocal;
                        }

                        result = DateTime.ParseExact(recordedDate, "\"UTC\" yyyy-MM-dd HH:mm:ss",
                            CultureInfo.InvariantCulture, dateTimeStyles);
                    }
                }

                if (result == null)
                {
                    recordedDate = mediaInfo.Get(StreamKind.General, 0, "Mastered_Date");
                    if (!string.IsNullOrWhiteSpace(recordedDate))
                    {
                        result = DateTime.ParseExact(recordedDate, "ddd MMM dd HH:mm:ss yyyy",
                            CultureInfo.InvariantCulture, DateTimeStyles.AssumeLocal);
                    }
                }
                return result;
            }
            catch (Exception)
            {
            }
            finally
            {
                if (mediaInfo != null)
                {
                    mediaInfo.Close();
                }
            }
            return null;
        }
开发者ID:anton-iermolenko,项目名称:Photo-library-toolkit,代码行数:60,代码来源:VideoInfo.cs

示例4: FileInput

            public FileInput(string filename)
            {
                this.filename = filename;
                MediaInfo MI = new MediaInfo();
                if (MI.Open(this.GetFileName()) > 0)
                {

                    string s = MI.Option("Info_Parameters");

                    int width = int.Parse(MI.Get(StreamKind.Video, 0, "Width"));
                    int height = int.Parse(MI.Get(StreamKind.Video, 0, "Height"));
                    decimal aspect = (decimal)width / (decimal)height;
                    bool resize = false;
                    if (width > 1280)
                    {
                        width = 1280;
                        height = (int)(width / aspect);
                        resize = true;
                    }
                    if (height > 720)
                    {
                        height = 720;
                        width = (int)(height * aspect);
                        resize = true;
                    }
                    if (resize)
                    {
                        if (width % 2 > 0)
                            width -= 1;
                        if (height % 2 > 0)
                            height -= 1;
                        this._size = " -s " + width + "x" + height;
                    }
                    Log.WriteLine("resize=" + resize + ",size=" + width + "x" + height);


                    int videobitrate = int.Parse(MI.Get(StreamKind.Video, 0, "BitRate"));
                    if (videobitrate > 7 * 1024 * 1024 || resize)
                    {
                        this._parameter = " libx264 -coder 0 -flags -loop -cmp +chroma -partitions -parti8x8-parti4x4-partp8x8-partb8x8 -me_method dia -subq 0 -me_range 16 -g 250 -keyint_min 25 -sc_threshold 0 -i_qfactor 0.71 -b_strategy 0 -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -bf 0 -refs 1 -directpred 1 -trellis 0 -flags2 -bpyramid-mixed_refs-wpred-dct8x8+fastpskip-mbtree -wpredp 0 -b 4096k ";
                    }
                    else
                    {
                        this._parameter = " copy";
                    }
                    this._parameter = " -vcodec " + this._parameter;
                    //Log.WriteLine("media info supported :" + s);

                    MI.Close();
                }


                if (this.GetFileName().ToLower().EndsWith(".mp4") || this.GetFileName().ToLower().EndsWith(".mkv"))
                {
                    this._parameter += " -vbsf h264_mp4toannexb ";
                }
                this._parameter += " -acodec libfaac -ac 2 -ab 192k ";
            }
开发者ID:jorgeantwan18,项目名称:rokumedia,代码行数:58,代码来源:FileHttpLiveStreaming.cs

示例5: Main

        public static void Main()
        {
            MediaInfo MI = new MediaInfo();

            //change the files accordingly, tested with .avi, .mpg, .mpeg - these should be enough
            MI.Open("1.flv"); 

            string display = "";
            display += "FileName: " + MI.Get(0, 0, "FileName") + "\n";
            display += "FileExtension: " + MI.Get(0, 0, "FileExtension") + "\n";
            display += "Title: " + MI.Get(0, 0, "Title") + "\n";
            display += "Subtitle: " + MI.Get(0, 0, "Title/More") + "\n";
            display += "Tags: " + MI.Get(0, 0, "WM/Category") + "\n";
            display += "Comments: " + MI.Get(0, 0, "Comment") + "\n";

            string sizeInKBStr = MI.Get(0, 0, "FileSize/String").Substring(0, MI.Get(0, 0, "FileSize/String").LastIndexOf(" ")).Replace(" ", "");
            double sizeInKB = Double.Parse(sizeInKBStr);
            double sizeInMB = (double)(sizeInKB / 1024);
            string sizeInMBStr = String.Format("{0:0.00}", sizeInMB); 
            display += "Size: " + sizeInMBStr + " MB" + "\n";
            display += "Date created: " + MI.Get(0, 0, "File_Created_Date").Substring(MI.Get(0, 0, "File_Created_Date").IndexOf(" ") + 1, MI.Get(0, 0, "File_Created_Date").LastIndexOf(".")-4) + "\n";
            display += "Date modified: " + MI.Get(0, 0, "File_Modified_Date").Substring(MI.Get(0, 0, "File_Modified_Date").IndexOf(" ") + 1, MI.Get(0, 0, "File_Modified_Date").LastIndexOf(".")-4) + "\n";

            display += "\nVIDEO\n";
            display += "Length: " + MI.Get(0, 0, "Duration/String3").Substring(0, MI.Get(0, 0, "Duration/String3").LastIndexOf(".")) + "\n";
            display += "Frame width: " + MI.Get(StreamKind.Video, 0, "Width/String") + "\n";
            display += "Frame height: " + MI.Get(StreamKind.Video, 0, "Height/String") + "\n";
            if (MI.Get(StreamKind.Video, 0, "BitRate/String") != "")
                display += "Data rate: " + MI.Get(StreamKind.Video, 0, "BitRate/String").Substring(0, MI.Get(StreamKind.Video, 0, "BitRate/String").LastIndexOf(" ")).Replace(" ", "") + " kbps" + "\n";
            else
                display += "Data rate:\n";
            string frameRateOriStr = MI.Get(StreamKind.Video, 0, "FrameRate/String").Substring(0, MI.Get(StreamKind.Video, 0, "FrameRate/String").LastIndexOf(" ")).Replace(" ", "");
            double frameRate = Double.Parse(frameRateOriStr);
            string frameRateStr = String.Format("{0:0}", frameRate);
            display += "Frame rate: " + frameRateStr + " fps" + "\n";

            display += "\nAUDIO\n";
            string bitrateOriStr = MI.Get(StreamKind.Audio, 0, "BitRate/String").Substring(0, MI.Get(StreamKind.Audio, 0, "BitRate/String").LastIndexOf(" ")).Replace(" ", "");
            double bitrateRate = Double.Parse(bitrateOriStr);
            string bitrateRateStr = String.Format("{0:0}", bitrateRate);
            display += "Bitrate: " + bitrateRateStr + " kbps" + "\n";
            display += "Channels: " + MI.Get(StreamKind.Audio, 0, "Channel(s)/String") + "\n";
            string audioSampleRateOriStr = MI.Get(StreamKind.Audio, 0, "SamplingRate/String").Substring(0, MI.Get(StreamKind.Audio, 0, "SamplingRate/String").LastIndexOf(" ")).Replace(" ", "");
            double audioSampleRate = Double.Parse(audioSampleRateOriStr);
            string audioSampleRateStr = String.Format("{0:0}", audioSampleRate);
            display += "Audio sample rate: " + audioSampleRateStr + " kHz" + "\n";

            display += "\nMEDIA\n";
            display += "Artist: " + MI.Get(0, 0, "Performer") + "\n";
            display += "Year: " + MI.Get(0, 0, "Recorded_Date") + "\n";
            display += "Genre: " + MI.Get(0, 0, "Genre") + "\n";            

            MI.Close();

            Console.WriteLine(display);

        }
开发者ID:angad,项目名称:PeopleBAWX,代码行数:57,代码来源:Program.cs

示例6: Musiikki

 public Musiikki(string nimi, string filePath)
 {
     FilePath = filePath;
     MediaInfo MI = new MediaInfo();
     MI.Open(FilePath);
     Nimi = MI.Get(StreamKind.General, 0, "FileName");
     Pituus = MI.Get(StreamKind.General, 0, "Duration/String");
     SoundEncoding = MI.Get(StreamKind.Audio, 0, "Language/String") + "," + MI.Get(StreamKind.Audio, 0, "SamplingRate/String") + "," + MI.Get(StreamKind.Audio, 0, "Channel(s)/String") + "," + MI.Get(StreamKind.General, 0, "Audio_Format_List");
     TiedostonKoko = MI.Get(StreamKind.General, 0, "FileSize/String");
     MI.Close();
 }
开发者ID:Jeeqqq,项目名称:IIO13200-HTYO-Shareyourmovies,代码行数:11,代码来源:Musiikki.cs

示例7: AudioMetadata

 public AudioMetadata(string Filename)
 {
     var MI = new MediaInfo();
     MI.Open(Filename);
     Title = MI.Get(StreamKind.General, 0, "Title");
     Album = MI.Get(StreamKind.General, 0, "Album");
     Artist = MI.Get(StreamKind.General, 0, "Performer");
     Genre = MI.Get(StreamKind.General, 0, "Genre");
     RecordDate = MI.Get(StreamKind.General, 0, "Recorded_Date");
     var duration = MI.Get(StreamKind.General, 0, "Duration");
     Duration = new TimeSpan(Convert.ToInt64(duration) * 10000);
 }
开发者ID:bngreen,项目名称:Audio-Player,代码行数:12,代码来源:AudioMetadata.cs

示例8: Elokuva

 public Elokuva(string nimi, string filePath)
 {
     Watched = false;
     FilePath = filePath;
     MediaInfo MI = new MediaInfo();
     MI.Open(FilePath);
     nimi = MI.Get(StreamKind.General, 0, "FileName");
     Nimi = TrimNimi(nimi);
     Pituus = MI.Get(StreamKind.General, 0, "Duration/String");
     VideoEncoding = MI.Get(StreamKind.General, 0, "Format");
     SoundEncoding = MI.Get(StreamKind.Audio, 0, "Language/String") + "," + MI.Get(StreamKind.Audio, 0, "SamplingRate/String") + "," + MI.Get(StreamKind.Audio, 0, "Channel(s)/String") + "," + MI.Get(StreamKind.General, 0, "Audio_Format_List");
     TiedostonKoko = MI.Get(StreamKind.General, 0, "FileSize/String");
     Fps = MI.Get(StreamKind.Video, 0, "FrameRate/String");
     Resolution = MI.Get(StreamKind.Video, 0, "Width") + "x" + MI.Get(StreamKind.Video, 0, "Height");
     MI.Close();
     Movie movie = Search.getMovieInfoFromDb(Nimi);
       //  movie.Elokuva = this;
     DbTiedot=movie;
 }
开发者ID:Jeeqqq,项目名称:IIO13200-HTYO-Shareyourmovies,代码行数:19,代码来源:Elokuvat.cs

示例9: Main

        public static void Main(string[] args)
        {
            String ToDisplay = "";
            MediaInfo MI = new MediaInfo();
            //An example of how to use the library
            ToDisplay += "\r\n\r\nOpen\r\n";
            MI.Open(args[0]);

            ToDisplay += "\r\n\r\nInform with Complete=false\r\n";
            MI.Option("Complete");
            ToDisplay += MI.Inform();

            ToDisplay += "\r\n\r\nInform with Complete=true\r\n";
            MI.Option("Complete", "1");
            ToDisplay += MI.Inform();

            ToDisplay += "\r\n\r\nCustom Inform\r\n";
            MI.Option("Inform", "General;File size is %FileSize% bytes");
            ToDisplay += MI.Inform();

            ToDisplay += "\r\n\r\nGet with Stream=General and Parameter='FileSize'\r\n";
            ToDisplay += MI.Get(0, 0, "FileSize");

            ToDisplay += "\r\n\r\nGet with Stream=General and Parameter=46\r\n";
            ToDisplay += MI.Get(0, 0, 46);

            ToDisplay += "\r\n\r\nCount_Get with StreamKind=Stream_Audio\r\n";
            ToDisplay += MI.Count_Get(StreamKind.Audio);

            ToDisplay += "\r\n\r\nGet with Stream=General and Parameter='AudioCount'\r\n";
            ToDisplay += MI.Get(StreamKind.General, 0, "AudioCount");

            ToDisplay += "\r\n\r\nGet with Stream=Audio and Parameter='StreamCount'\r\n";
            ToDisplay += MI.Get(StreamKind.Audio, 0, "StreamCount");

            ToDisplay += "\r\n\r\nClose\r\n";
            MI.Close();

            Console.WriteLine(ToDisplay);
        }
开发者ID:lovebomb,项目名称:linkwithweb,代码行数:40,代码来源:MediaInfoRead.cs

示例10: x264StartBtn_Click

        private void x264StartBtn_Click(object sender, EventArgs e)
        {
            #region validation

            if (string.IsNullOrEmpty(namevideo2))
            {
                ShowErrorMessage("请选择视频文件");
                return;
            }

            if (!string.IsNullOrEmpty(namesub2) && !File.Exists(namesub2))
            {
                ShowErrorMessage("字幕文件不存在,请重新选择");
                return;
            }

            if (string.IsNullOrEmpty(nameout2))
            {
                ShowErrorMessage("请选择输出文件");
                return;
            }

            if (x264ExeComboBox.SelectedIndex == -1)
            {
                ShowErrorMessage("请选择X264程序");
                return;
            }

            if (AudioEncoderComboBox.SelectedIndex != 0 && AudioEncoderComboBox.SelectedIndex != 1 && AudioEncoderComboBox.SelectedIndex != 5)
            {
                ShowWarningMessage("音频页面中的编码器未采用AAC将可能导致压制失败,建议将编码器改为QAAC、NeroAAC或FDKAAC。");
            }

            //防止未选择 x264 thread
            if (x264ThreadsComboBox.SelectedIndex == -1)
            {
                x264ThreadsComboBox.SelectedIndex = 0;
            }

            //目标文件已经存在提示是否覆盖
            if (File.Exists(x264OutTextBox.Text.Trim()))
            {
                DialogResult dgs = ShowQuestion("目标文件:\r\n\r\n" + x264OutTextBox.Text.Trim() + "\r\n\r\n已经存在,是否覆盖继续压制?", "目标文件已经存在");
                if (dgs == DialogResult.No) return;
            }

            //如果是AVS复制到C盘根目录
            if (Path.GetExtension(x264VideoTextBox.Text) == ".avs")
            {
                if (string.IsNullOrEmpty(Util.CheckAviSynth()) && string.IsNullOrEmpty(Util.CheckinternalAviSynth()))
                {
                    if (ShowQuestion("检测到本机未安装avisynth无法继续压制,是否去下载安装", "avisynth未安装") == DialogResult.Yes)
                        Process.Start("http://sourceforge.net/projects/avisynth2/");
                    return;
                }
                //if (File.Exists(tempavspath)) File.Delete(tempavspath);
                File.Copy(x264VideoTextBox.Text, tempavspath, true);
                namevideo2 = tempavspath;
                x264DemuxerComboBox.SelectedIndex = 0; //压制AVS始终使用分离器为auto
            }

            #endregion validation

            string ext = Path.GetExtension(nameout2).ToLower();
            bool hasAudio = false;
            string inputName = Path.GetFileNameWithoutExtension(namevideo2);
            string tempVideo = Path.Combine(tempfilepath, inputName + "_vtemp.mp4");
            string tempAudio = Path.Combine(tempfilepath, inputName + "_atemp" + getAudioExt());
            Util.ensureDirectoryExists(tempfilepath);

            #region Audio

            //检测是否含有音频
            MediaInfo MI = new MediaInfo();
            MI.Open(namevideo2);
            string audio = MI.Get(StreamKind.Audio, 0, "Format");
            if (!string.IsNullOrEmpty(audio))
                hasAudio = true;
            int audioMode = x264AudioModeComboBox.SelectedIndex;
            if (!hasAudio && x264AudioModeComboBox.SelectedIndex != 1)
            {
                DialogResult r = ShowQuestion("原视频不包含音频流,音频模式是否改为无音频流?", "提示");
                if (r == DialogResult.Yes)
                    audioMode = 1;
            }
            switch (audioMode)
            {
                case 0:
                    aextract = audiobat(namevideo2, tempAudio);
                    break;
                case 1:
                    aextract = string.Empty;
                    break;
                case 2:
                    if (audio.ToLower() == "aac")
                    {
                        tempAudio = Path.Combine(tempfilepath, inputName + "_atemp.aac");
                        aextract = ExtractAudio(namevideo2, tempAudio);
                    }
                    else
//.........这里部分代码省略.........
开发者ID:celeron533,项目名称:marukotoolbox,代码行数:101,代码来源:MainForm.cs

示例11: x264bat

        public string x264bat(string input, string output, int pass = 1, string sub = "")
        {
            StringBuilder sb = new StringBuilder();
            //keyint设为fps的10倍
            MediaInfo MI = new MediaInfo();
            MI.Open(input);
            string frameRate = MI.Get(StreamKind.Video, 0, "FrameRate");
            double fps;
            string keyint = "-1";
            if (double.TryParse(frameRate, out fps))
            {
                fps = Math.Round(fps);
                keyint = (fps * 10).ToString();
            }

            if (Path.GetExtension(input) == ".avs")
                sb.Append("\"" + workPath + "\\avs4x26x.exe\"" + " -L ");
            sb.Append("\"" + Path.Combine(workPath, x264ExeComboBox.SelectedItem.ToString()) + "\"");
            // 编码模式
            switch (x264mode)
            {
                case 0: // 自定义
                    sb.Append(" " + x264CustomParameterTextBox.Text);
                    break;

                case 1: // crf
                    sb.Append(" --crf " + x264CRFNum.Value);
                    break;

                case 2: // 2pass
                    sb.Append(" --pass " + pass + " --bitrate " + x264BitrateNum.Value + " --stats \"" + Path.Combine(tempfilepath, Path.GetFileNameWithoutExtension(output)) + ".stats\"");
                    break;
            }
            if (x264mode != 0)
            {
                if (x264DemuxerComboBox.Text != "auto" && x264DemuxerComboBox.Text != string.Empty)
                    sb.Append(" --demuxer " + x264DemuxerComboBox.Text);
                if (x264ThreadsComboBox.SelectedItem.ToString() != "auto" && x264ThreadsComboBox.SelectedItem.ToString() != string.Empty)
                    sb.Append(" --threads " + x264ThreadsComboBox.SelectedItem.ToString());
                if (x264extraLine.Text != string.Empty)
                    sb.Append(" " + x264extraLine.Text);
                else
                    sb.Append(" --preset 8 " + " -I " + keyint + " -r 4 -b 3 --me umh -i 1 --scenecut 60 -f 1:1 --qcomp 0.5 --psy-rd 0.3:0 --aq-mode 2 --aq-strength 0.8");
                if (x264HeightNum.Value != 0 && x264WidthNum.Value != 0 && !MaintainResolutionCheckBox.Checked)
                    sb.Append(" --vf resize:" + x264WidthNum.Value + "," + x264HeightNum.Value + ",,,,lanczos");
            }
            if (!string.IsNullOrEmpty(sub))
            {
                string x264tmpline = sb.ToString();
                if (x264tmpline.IndexOf("--vf") == -1)
                    sb.Append(" --vf subtitles --sub \"" + sub + "\"");
                else
                {
                    Regex r = new Regex("--vf\\s\\S*");
                    Match m = r.Match(x264tmpline);
                    sb.Insert(m.Index + 5, "subtitles/").Append(" --sub \"" + sub + "\"");
                }
            }
            if (x264SeekNumericUpDown.Value != 0)
                sb.Append(" --seek " + x264SeekNumericUpDown.Value.ToString());
            if (x264FramesNumericUpDown.Value != 0)
                sb.Append(" --frames " + x264FramesNumericUpDown.Value.ToString());
            if (x264mode == 2 && pass == 1)
                sb.Append(" -o NUL");
            else if (!string.IsNullOrEmpty(output))
                sb.Append(" -o " + "\"" + output + "\"");
            if (!string.IsNullOrEmpty(input))
                sb.Append(" \"" + input + "\"");
            return sb.ToString();
        }
开发者ID:celeron533,项目名称:marukotoolbox,代码行数:70,代码来源:MainForm.cs

示例12: btnAVS9_Click

        private void btnAVS9_Click(object sender, EventArgs e)
        {
            x264DemuxerComboBox.SelectedIndex = 0; //压制AVS始终使用分离器为auto

            if (string.IsNullOrEmpty(nameout9))
            {
                ShowErrorMessage("请选择输出文件");
                return;
            }

            if (Path.GetExtension(nameout9).ToLower() != ".mp4")
            {
                ShowErrorMessage("仅支持MP4输出", "不支持的输出格式");
                return;
            }

            if (File.Exists(txtout9.Text.Trim()))
            {
                DialogResult dgs = ShowQuestion("目标文件:\r\n\r\n" + txtout9.Text.Trim() + "\r\n\r\n已经存在,是否覆盖继续压制?", "目标文件已经存在");
                if (dgs == DialogResult.No) return;
            }

            if (string.IsNullOrEmpty(Util.CheckAviSynth()) && string.IsNullOrEmpty(Util.CheckinternalAviSynth()))
            {
                if (ShowQuestion("检测到本机未安装avisynth无法继续压制,是否去下载安装", "avisynth未安装") == DialogResult.Yes)
                    Process.Start("http://sourceforge.net/projects/avisynth2/");
                return;
            }

            string inputName = Path.GetFileNameWithoutExtension(namevideo9);
            string tempVideo = Path.Combine(tempfilepath, inputName + "_vtemp.mp4");
            string tempAudio = Path.Combine(tempfilepath, inputName + "_atemp" + getAudioExt());
            Util.ensureDirectoryExists(tempfilepath);

            string filepath = tempavspath;
            //string filepath = workpath + "\\temp.avs";
            File.WriteAllText(filepath, AVSScriptTextBox.Text, Encoding.Default);

            //检测是否含有音频
            bool hasAudio = false;
            MediaInfo MI = new MediaInfo();
            MI.Open(namevideo9);
            string audio = MI.Get(StreamKind.Audio, 0, "Format");
            if (!string.IsNullOrEmpty(audio)) { hasAudio = true; }

            //audio
            if (AVSwithAudioCheckBox.Checked && hasAudio)
            {
                if (!File.Exists(txtvideo9.Text))
                {
                    ShowErrorMessage("请选择视频文件");
                    return;
                }
                aextract = audiobat(namevideo9, tempAudio);
            }
            else
                aextract = string.Empty;

            //video
            if (x264ExeComboBox.SelectedItem.ToString().ToLower().Contains("x264"))
            {
                if (x264mode == 2)
                    x264 = x264bat(filepath, tempVideo, 1) + "\r\n" +
                           x264bat(filepath, tempVideo, 2);
                else x264 = x264bat(filepath, tempVideo);
                if (!AVSwithAudioCheckBox.Checked || !hasAudio)
                    x264 = x264.Replace(tempVideo, nameout9);
            }
            else if (x264ExeComboBox.SelectedItem.ToString().ToLower().Contains("x265"))
            {
                tempVideo = Path.Combine(tempfilepath, inputName + "_vtemp.hevc");
                if (x264mode == 2)
                    x264 = x265bat(filepath, tempVideo, 1) + "\r\n" +
                           x265bat(filepath, tempVideo, 2);
                else x264 = x265bat(filepath, tempVideo);
                if (!AVSwithAudioCheckBox.Checked || !hasAudio)
                {
                    x264 += "\r\n\"" + workPath + "\\mp4box.exe\"  -add  \"" + tempVideo + "#trackID=1:name=\" -new \"" + nameout9 + "\" \r\n";
                    x264 += "del \"" + tempVideo + "\"";
                }
            }
            //mux
            if (AVSwithAudioCheckBox.Checked && hasAudio) //如果包含音频
                mux = boxmuxbat(tempVideo, tempAudio, nameout9);
            else
                mux = string.Empty;

            auto = aextract + x264 + "\r\n" + mux + " \r\n";
            auto += "\r\necho ===== one file is completed! =====\r\n";
            LogRecord(auto);
            Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(GetCultureName());
            WorkingForm wf = new WorkingForm(auto);
            wf.Owner = this;
            wf.Show();
            //auto += "\r\ncmd";
            //batpath = workPath + "\\x264avs.bat";
            //File.WriteAllText(batpath, auto, Encoding.Default);
            //Process.Start(batpath);
        }
开发者ID:celeron533,项目名称:marukotoolbox,代码行数:99,代码来源:MainForm.cs

示例13: btnBatchMP4_Click

        private void btnBatchMP4_Click(object sender, EventArgs e)
        {
            if (lbffmpeg.Items.Count != 0)
            {
                string ext = MuxFormatComboBox.Text;
                string mux = "";
                for (int i = 0; i < lbffmpeg.Items.Count; i++)
                {
                    string filePath = lbffmpeg.Items[i].ToString();
                    //如果是源文件的格式和目标格式相同则跳过
                    if (Path.GetExtension(filePath).Contains(ext))
                        continue;
                    string finish = Path.ChangeExtension(filePath, ext);
                    aextract = "";

                    //检测音频是否需要转换为AAC
                    MediaInfo MI = new MediaInfo();
                    MI.Open(filePath);
                    string audio = MI.Get(StreamKind.Audio, 0, "Format");
                    if (audio.ToLower() != "aac")
                    {
                        mux += "\"" + workPath + "\\ffmpeg.exe\" -y -i \"" + lbffmpeg.Items[i].ToString() + "\" -c:v copy -c:a " + MuxAacEncoderComboBox.Text + " -strict -2 \"" + finish + "\" \r\n";
                    }
                    else
                    {
                        mux += "\"" + workPath + "\\ffmpeg.exe\" -y -i \"" + lbffmpeg.Items[i].ToString() + "\" -c copy \"" + finish + "\" \r\n";
                    }
                }
                mux += "\r\ncmd";
                batpath = workPath + "\\mux.bat";
                File.WriteAllText(batpath, mux, Encoding.Default);
                LogRecord(mux);
                Process.Start(batpath);
            }
            else ShowErrorMessage("请输入视频!");
        }
开发者ID:celeron533,项目名称:marukotoolbox,代码行数:36,代码来源:MainForm.cs

示例14: IndexCrop

        private bool IndexCrop()
        {
            try
            {
                DoPlugin(PluginType.BeforeAutoCrop);

                string filename = "";
                AdvancedVideoOptions avo = null;
                foreach (StreamInfo si in demuxedStreamList.streams)
                {
                    if (si.streamType == StreamType.Video)
                    {
                        filename = si.filename;
                        if (si.advancedOptions != null && si.advancedOptions.GetType() == typeof(AdvancedVideoOptions)) avo = (AdvancedVideoOptions)si.advancedOptions;
                        break;
                    }
                }

                string fps = "";
                string resX = "";
                string resY = "";
                string length = "";
                string frames = "";

                try
                {
                    MediaInfoLib.MediaInfo mi2 = new MediaInfoLib.MediaInfo();
                    mi2.Open(filename);
                    mi2.Option("Complete", "1");
                    string[] tmpstr = mi2.Inform().Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);
                    foreach (string s in tmpstr)
                    {
                        logWindow.MessageCrop(s.Trim());
                    }
                    if (mi2.Count_Get(StreamKind.Video) > 0)
                    {
                        fps = mi2.Get(StreamKind.Video, 0, "FrameRate");
                        resX = mi2.Get(StreamKind.Video, 0, "Width");
                        resY = mi2.Get(StreamKind.Video, 0, "Height");
                        length = mi2.Get(StreamKind.Video, 0, "Duration");
                        frames = mi2.Get(StreamKind.Video, 0, "FrameCount");
                    }
                    mi2.Close();
                }
                catch (Exception ex)
                {
                    logWindow.MessageCrop(Global.Res("ErrorMediaInfo") + " " + ex.Message);
                    return false;
                }

                if (avo != null && avo.disableFps)
                {
                    logWindow.MessageCrop(Global.Res("InfoManualFps"));
                    fps = avo.fps;
                    length = avo.length;
                    frames = avo.frames;
                }

                if (fps == "")
                {
                    logWindow.MessageCrop(Global.Res("ErrorFramerate"));
                    foreach (StreamInfo si in demuxedStreamList.streams)
                    {
                        if (si.streamType == StreamType.Video)
                        {
                            if (si.desc.Contains("24 /1.001"))
                            {
                                logWindow.MessageCrop(Global.ResFormat("InfoFps", " 23.976"));
                                fps = "23.976";
                                break;
                            }
                            else if (si.desc.Contains("1080p24 (16:9)"))
                            {
                                logWindow.MessageCrop(Global.ResFormat("InfoFps", " 24"));
                                fps = "24";
                                break;
                            }
                            // add other framerates here
                        }
                    }
                    if (fps == "")
                    {
                        logWindow.MessageCrop(Global.Res("ErrorNoFramerate"));
                        return false;
                    }
                }

                if (frames == "" || length == "")
                {
                    logWindow.MessageCrop(Global.Res("InfoFrames"));
                }

                CropInfo cropInfo = new CropInfo();
                if (!settings.untouchedVideo)
                {
                    if (settings.cropInput == 1 || settings.encodeInput == 1)
                    {
                        bool skip = false;
                        if (File.Exists(filename + ".ffindex") && !settings.deleteIndex)
                        {
//.........这里部分代码省略.........
开发者ID:CommanderBubble,项目名称:Blurip,代码行数:101,代码来源:IndexCrop.cs

示例15: Form1_Load

		private void Form1_Load(object sender, System.EventArgs e)
		{
			//Test if version of DLL is compatible : 3rd argument is "version of DLL tested;Your application name;Your application version"
            String ToDisplay;
            MediaInfo MI = new MediaInfo();

            ToDisplay = MI.Option("Info_Version", "0.7.0.0;MediaInfoDLL_Example_CS;0.7.0.0");
			if (ToDisplay.Length == 0)
			{
                richTextBox1.Text = "MediaInfo.Dll: this version of the DLL is not compatible";
				return;
			}

			//Information about MediaInfo
			ToDisplay += "\r\n\r\nInfo_Parameters\r\n";
			ToDisplay += MI.Option("Info_Parameters");

			ToDisplay += "\r\n\r\nInfo_Capacities\r\n";
            ToDisplay += MI.Option("Info_Capacities");

			ToDisplay += "\r\n\r\nInfo_Codecs\r\n";
            ToDisplay += MI.Option("Info_Codecs");

			//An example of how to use the library
			ToDisplay += "\r\n\r\nOpen\r\n";
			MI.Open("Example.ogg");

			ToDisplay += "\r\n\r\nInform with Complete=false\r\n";
			MI.Option("Complete");
			ToDisplay += MI.Inform();

            ToDisplay += "\r\n\r\nInform with Complete=true\r\n";
			MI.Option("Complete", "1");
			ToDisplay += MI.Inform();

            ToDisplay += "\r\n\r\nCustom Inform\r\n";
            MI.Option("Inform", "General;File size is %FileSize% bytes");
            ToDisplay += MI.Inform();

            ToDisplay += "\r\n\r\nGet with Stream=General and Parameter='FileSize'\r\n";
            ToDisplay += MI.Get(0, 0, "FileSize");

            ToDisplay += "\r\n\r\nGet with Stream=General and Parameter=46\r\n";
            ToDisplay += MI.Get(0, 0, 46);

            ToDisplay += "\r\n\r\nCount_Get with StreamKind=Stream_Audio\r\n";
            ToDisplay += MI.Count_Get(StreamKind.Audio);

            ToDisplay += "\r\n\r\nGet with Stream=General and Parameter='AudioCount'\r\n";
            ToDisplay += MI.Get(StreamKind.General, 0, "AudioCount");

            ToDisplay += "\r\n\r\nGet with Stream=Audio and Parameter='StreamCount'\r\n";
            ToDisplay += MI.Get(StreamKind.Audio, 0, "StreamCount");

            ToDisplay += "\r\n\r\nClose\r\n";
            MI.Close();

			//Example with a stream
            //ToDisplay+="\r\n"+ExampleWithStream()+"\r\n";

            //Displaying the text
			richTextBox1.Text = ToDisplay;
		}
开发者ID:bedashii,项目名称:ReturnMedz,代码行数:63,代码来源:HowToUse_Dll.cs


注:本文中的MediaInfoLib.MediaInfo.Open方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。