Ejemplo n.º 1
0
        public AboutBox()
        {
            InitializeComponent();
            Text = String.Format("About {0}", AssemblyTitle);
            labelProductName.Text = AssemblyProduct;
            labelVersion.Text     = String.Format("Version {0}", AssemblyVersion);
            labelCopyright.Text   = AssemblyCopyright;
            StringBuilder sbDesc = new StringBuilder();

            sbDesc.AppendLine(AssemblyDescription);
            sbDesc.AppendLine();
            sbDesc.AppendLine("Running from:");
            sbDesc.AppendLine(Application.StartupPath);
            sbDesc.AppendLine();
            sbDesc.AppendLine("Settings file:");
            sbDesc.AppendLine(App.SettingsFilePath);
            MediaInfoLib.MediaInfo mi = new MediaInfoLib.MediaInfo();
            sbDesc.AppendLine();
            sbDesc.AppendLine("External libraries:");
            sbDesc.AppendLine("ShareX: http://getsharex.com");
            sbDesc.AppendLine(mi.Option("Info_Version") + ": http://sourceforge.net/projects/mediainfo");
            textBoxDescription.Text = sbDesc.ToString();

            UpdateChecker updateChecker = ProgramUI.UpdateManager.CreateUpdateChecker();

            uclUpdate.CheckUpdate(updateChecker);
        }
Ejemplo n.º 2
0
        public MediaInfo(Models.FileName file)
        {
            InitializeComponent();
            this.Text = file.Original;

            string result;

            if (IntPtr.Size == 4)
            {
                var MI = new MediaInfoLib.MediaInfo();

                MI.Open(file.FullPath());
                MI.Option("Complete");
                result = MI.Inform();
                MI.Close();
            }
            else
            {
                var MI = new MediaInfoLib.MediaInfo64();

                MI.Open(file.FullPath());
                MI.Option("Complete");
                result = MI.Inform();
                MI.Close();
            }

            var sp = result
                     .TrimEnd(new char[] { '\r', '\n' })
                     .Split(new string[] { "\r\n" }, StringSplitOptions.None);

            TreeNode root = null;

            foreach (var s in sp)
            {
                if (root == null)
                {
                    root = new TreeNode(s);
                    treeViewInfo.Nodes.Add(root);
                }
                else
                {
                    if (s == "")
                    {
                        root = null;
                    }
                    else
                    {
                        root.Nodes.Add(new TreeNode(Regex.Replace(s, "\\s{2,}", "")));
                    }
                }
            }

            treeViewInfo.ExpandAll();
        }
Ejemplo n.º 3
0
 private void showMediaInformation(string filePath)
 {
     richTextBox_ImageProperties.AppendLine(filePath);
     try
     {
         MediaInfoLib.MediaInfo mediaInfo = new MediaInfoLib.MediaInfo();
         if (mediaInfo.Open(filePath) == 1)
         {
             mediaInfo.Option("Complete", "1");
             richTextBox_ImageProperties.AppendLine(CultureStrings.ColonMediaInformation);
             richTextBox_ImageProperties.AppendLine(mediaInfo.Inform());
         }
         mediaInfo.Close();
     }
     catch (System.Exception ex)
     {
         logException(ex);
     }
 }
Ejemplo n.º 4
0
        public AboutBox()
        {
            InitializeComponent();
            Text = String.Format("About {0}", AssemblyTitle);
            labelProductName.Text = AssemblyProduct;
            labelVersion.Text = String.Format("Version {0}", AssemblyVersion);
            labelCopyright.Text = AssemblyCopyright;
            StringBuilder sbDesc = new StringBuilder();
            sbDesc.AppendLine(AssemblyDescription);
            sbDesc.AppendLine();
            sbDesc.AppendLine("Running from:");
            sbDesc.AppendLine(Application.StartupPath);
            sbDesc.AppendLine();
            sbDesc.AppendLine("Settings file:");
            sbDesc.AppendLine(App.SettingsFilePath);
            MediaInfoLib.MediaInfo mi = new MediaInfoLib.MediaInfo();
            sbDesc.AppendLine();
            sbDesc.AppendLine("External libraries:");
            sbDesc.AppendLine("ShareX: http://getsharex.com");
            sbDesc.AppendLine(mi.Option("Info_Version") + ": http://sourceforge.net/projects/mediainfo");
            textBoxDescription.Text = sbDesc.ToString();

            uclUpdate.CheckUpdate(CheckUpdate);
        }
Ejemplo n.º 5
0
        public override TaskStatus Run()
        {
            Info("Generating MediaInfo informations...");

            bool success           = true;
            bool atLeastOneSucceed = false;

            var files = SelectFiles();

            if (files.Length > 0)
            {
                var mediaInfoPath = Path.Combine(Workflow.WorkflowTempFolder,
                                                 string.Format("MediaInfo_{0:yyyy-MM-dd-HH-mm-ss-fff}.xml", DateTime.Now));

                var xdoc = new XDocument(new XElement("Files"));
                foreach (FileInf file in files)
                {
                    try
                    {
                        if (xdoc.Root != null)
                        {
                            XElement xfile = new XElement("File",
                                                          new XAttribute("path", file.Path),
                                                          new XAttribute("name", file.FileName));

                            MediaInfoLib.MediaInfo mediaInfo = new MediaInfoLib.MediaInfo();
                            mediaInfo.Open(file.Path);
                            mediaInfo.Option("Complete", "1");
                            string   info  = mediaInfo.Inform();
                            string[] infos = info.Split(new [] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);

                            XElement xgeneral = null;
                            XElement xaudio   = null;
                            XElement xvideo   = null;

                            // Build xgeneral
                            foreach (var line in infos)
                            {
                                if (line == "General")
                                {
                                    xgeneral = new XElement("General");
                                    continue;
                                }

                                if (line == "Audio" || line == "Video")
                                {
                                    break;
                                }

                                string[] tag = line.Split(':');
                                xgeneral.Add(new XElement("Tag",
                                                          new XAttribute("name", tag[0].Trim()),
                                                          new XAttribute("value", tag[1].Trim())));
                            }

                            // Build xvideo
                            var xvideoFound = false;
                            foreach (var line in infos)
                            {
                                if (line == "Video")
                                {
                                    xvideoFound = true;
                                    xvideo      = new XElement("Video");
                                    continue;
                                }

                                if (line == "Audio")
                                {
                                    break;
                                }

                                if (xvideoFound)
                                {
                                    string[] tag = line.Split(':');
                                    xvideo.Add(new XElement("Tag",
                                                            new XAttribute("name", tag[0].Trim()),
                                                            new XAttribute("value", tag[1].Trim())));
                                }
                            }

                            // Build xaudio
                            var xaudioFound = false;
                            foreach (var line in infos)
                            {
                                if (line == "Audio")
                                {
                                    xaudioFound = true;
                                    xaudio      = new XElement("Audio");
                                    continue;
                                }

                                if (xaudioFound)
                                {
                                    string[] tag = line.Split(':');
                                    xaudio.Add(new XElement("Tag",
                                                            new XAttribute("name", tag[0].Trim()),
                                                            new XAttribute("value", tag[1].Trim())));
                                }
                            }

                            if (xgeneral != null)
                            {
                                xfile.Add(xgeneral);
                            }

                            if (xvideo != null)
                            {
                                xfile.Add(xvideo);
                            }

                            if (xaudio != null)
                            {
                                xfile.Add(xaudio);
                            }

                            xdoc.Root.Add(xfile);
                        }
                        InfoFormat("MediaInfo of the file {0} generated.", file.Path);

                        if (!atLeastOneSucceed)
                        {
                            atLeastOneSucceed = true;
                        }
                    }
                    catch (ThreadAbortException)
                    {
                        throw;
                    }
                    catch (Exception e)
                    {
                        ErrorFormat("An error occured while generating the mediaInfo of the file {0}", e, file.Path);
                        success = false;
                    }
                }
                xdoc.Save(mediaInfoPath);
                Files.Add(new FileInf(mediaInfoPath, Id));
            }

            var status = Status.Success;

            if (!success && atLeastOneSucceed)
            {
                status = Status.Warning;
            }
            else if (!success)
            {
                status = Status.Error;
            }

            Info("Task finished.");
            return(new TaskStatus(status, false));
        }
Ejemplo n.º 6
0
        public static XDocument Inform(FileInf[] files)
        {
            var xdoc = new XDocument(new XElement("Files"));

            foreach (FileInf file in files)
            {
                try
                {
                    if (xdoc.Root != null)
                    {
                        XElement xfile = new XElement("File",
                                                      new XAttribute("path", file.Path),
                                                      new XAttribute("name", file.FileName));

                        MediaInfoLib.MediaInfo mediaInfo = new MediaInfoLib.MediaInfo();
                        mediaInfo.Open(file.Path);
                        mediaInfo.Option("Complete", "1");
                        string   info  = mediaInfo.Inform();
                        string[] infos = info.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);

                        XElement xgeneral = null;
                        XElement xaudio   = null;
                        XElement xvideo   = null;

                        // Build xgeneral
                        foreach (var line in infos)
                        {
                            if (line == "General")
                            {
                                xgeneral = new XElement("General");
                                continue;
                            }

                            if (line == "Audio" || line == "Video")
                            {
                                break;
                            }

                            string[] tag = line.Split(':');
                            xgeneral.Add(new XElement("Tag",
                                                      new XAttribute("name", tag[0].Trim()),
                                                      new XAttribute("value", tag[1].Trim())));
                        }

                        // Build xvideo
                        var xvideoFound = false;
                        foreach (var line in infos)
                        {
                            if (line == "Video")
                            {
                                xvideoFound = true;
                                xvideo      = new XElement("Video");
                                continue;
                            }

                            if (xvideoFound)
                            {
                                if (line == "Audio")
                                {
                                    break;
                                }

                                string[] tag = line.Split(':');
                                xvideo.Add(new XElement("Tag",
                                                        new XAttribute("name", tag[0].Trim()),
                                                        new XAttribute("value", tag[1].Trim())));
                            }
                        }

                        // Build xaudio
                        var xaudioFound = false;
                        foreach (var line in infos)
                        {
                            if (line == "Audio")
                            {
                                xaudioFound = true;
                                xaudio      = new XElement("Audio");
                                continue;
                            }

                            if (xaudioFound)
                            {
                                if (line == "Video")
                                {
                                    break;
                                }

                                string[] tag = line.Split(':');
                                xaudio.Add(new XElement("Tag",
                                                        new XAttribute("name", tag[0].Trim()),
                                                        new XAttribute("value", tag[1].Trim())));
                            }
                        }

                        if (xgeneral != null)
                        {
                            xfile.Add(xgeneral);
                        }

                        if (xvideo != null)
                        {
                            xfile.Add(xvideo);
                        }

                        if (xaudio != null)
                        {
                            xfile.Add(xaudio);
                        }

                        xdoc.Root.Add(xfile);
                    }
                    Logger.InfoFormat("MediaInfo of the file {0} generated.", file.Path);

                    if (!_atLeastOneSucceed)
                    {
                        _atLeastOneSucceed = true;
                    }
                }
                catch (ThreadAbortException)
                {
                    throw;
                }
                catch (Exception e)
                {
                    Logger.ErrorFormat("An error occured while generating the mediaInfo of the file {0}", e, file.Path);
                    _success = false;
                }
            }
            return(xdoc);
        }
Ejemplo n.º 7
0
        private static void DisplayMediaInfo()
        {
            String ToDisplay;

            MediaInfoLib.MediaInfo MI = new MediaInfoLib.MediaInfo();

            ToDisplay = MI.Option("Info_Version", "0.7.0.0;MediaInfoDLL_Example_CS;0.7.0.0");
            if (ToDisplay.Length == 0)
            {
                Console.Write("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";
            ToDisplay += "\r\n\r\nClose\r\n==========================";
            ToDisplay += "\r\n\r\nClose\r\n==========================";
            MI.Open("d:\temp\test.mp4");

            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(MediaInfoLib.StreamKind.Audio);

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

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

            ToDisplay += "\r\n\r\nClose\r\n";
            MI.Close();
            ToDisplay += "\r\n\r\nClose\r\n==========================";
            //Example with a stream
            ToDisplay += "\r\n" + ReadMediaInfo() + "\r\n";

            //Displaying the text
            Console.Write(ToDisplay);
        }