Option() public method

public Option ( String Option_ ) : String
Option_ String
return String
            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 ";
            }
Beispiel #2
0
        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);
        }
Beispiel #3
0
 public AboutBox()
 {
     InitializeComponent();
     this.Text = String.Format("About {0}", AssemblyTitle);
     this.labelProductName.Text = AssemblyProduct;
     this.labelVersion.Text = String.Format("Version {0}", AssemblyVersion);
     this.labelCopyright.Text = AssemblyCopyright;
     this.labelCompanyName.Text = AssemblyCompany;
     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(Program.AppConf.XMLSettingsFile);
     MediaInfoLib.MediaInfo mi = new MediaInfoLib.MediaInfo();
     sbDesc.AppendLine();
     sbDesc.AppendLine("Using:");
     sbDesc.AppendLine(mi.Option("Info_Version") + " from http://sourceforge.net/projects/mediainfo");
     sbDesc.AppendLine("Movie Thumbnailer v200808a:");
     this.textBoxDescription.Text = sbDesc.ToString();
 }
        public virtual MediaInfoModel GetMediaInfo(string filename)
        {
            if (!_diskProvider.FileExists(filename))
                throw new FileNotFoundException("Media file does not exist: " + filename);

            var mediaInfo = new MediaInfo();

            try
            {
                logger.Trace("Getting media info from {0}", filename);

                mediaInfo.Option("ParseSpeed", "0.2");
                int open = mediaInfo.Open(filename);

                if (open != 0)
                {
                    int width;
                    int height;
                    int videoBitRate;
                    int audioBitRate;
                    int runTime;
                    int streamCount;
                    int audioChannels;

                    string subtitles = mediaInfo.Get(StreamKind.General, 0, "Text_Language_List");
                    string scanType = mediaInfo.Get(StreamKind.Video, 0, "ScanType");
                    Int32.TryParse(mediaInfo.Get(StreamKind.Video, 0, "Width"), out width);
                    Int32.TryParse(mediaInfo.Get(StreamKind.Video, 0, "Height"), out height);
                    Int32.TryParse(mediaInfo.Get(StreamKind.Video, 0, "BitRate"), out videoBitRate);

                    string aBitRate = mediaInfo.Get(StreamKind.Audio, 0, "BitRate");
                    int ABindex = aBitRate.IndexOf(" /");
                    if (ABindex > 0)
                        aBitRate = aBitRate.Remove(ABindex);

                    Int32.TryParse(aBitRate, out audioBitRate);
                    Int32.TryParse(mediaInfo.Get(StreamKind.General, 0, "PlayTime"), out runTime);
                    Int32.TryParse(mediaInfo.Get(StreamKind.Audio, 0, "StreamCount"), out streamCount);

                    string audioChannelsStr = mediaInfo.Get(StreamKind.Audio, 0, "Channel(s)");
                    int ACindex = audioChannelsStr.IndexOf(" /");
                    if (ACindex > 0)
                        audioChannelsStr = audioChannelsStr.Remove(ACindex);

                    string audioLanguages = mediaInfo.Get(StreamKind.General, 0, "Audio_Language_List");
                    decimal videoFrameRate = Decimal.Parse(mediaInfo.Get(StreamKind.Video, 0, "FrameRate"));
                    string audioProfile = mediaInfo.Get(StreamKind.Audio, 0, "Format_Profile");

                    int APindex = audioProfile.IndexOf(" /");
                    if (APindex > 0)
                        audioProfile = audioProfile.Remove(APindex);

                    Int32.TryParse(audioChannelsStr, out audioChannels);
                    var mediaInfoModel = new MediaInfoModel
                                                {
                                                    VideoCodec = mediaInfo.Get(StreamKind.Video, 0, "Codec/String"),
                                                    VideoBitrate = videoBitRate,
                                                    Height = height,
                                                    Width = width,
                                                    AudioFormat = mediaInfo.Get(StreamKind.Audio, 0, "Format"),
                                                    AudioBitrate = audioBitRate,
                                                    RunTime = (runTime / 1000), //InSeconds
                                                    AudioStreamCount = streamCount,
                                                    AudioChannels = audioChannels,
                                                    AudioProfile = audioProfile.Trim(),
                                                    VideoFps = videoFrameRate,
                                                    AudioLanguages = audioLanguages,
                                                    Subtitles = subtitles,
                                                    ScanType = scanType
                                                };

                    mediaInfo.Close();
                    return mediaInfoModel;
                }
            }
            catch (Exception ex)
            {
                logger.ErrorException("Unable to parse media info from file: " + filename, ex);
                mediaInfo.Close();
            }

            return null;
        }
Beispiel #5
0
        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)
                        {
                            skip = true;
                        }
                        if (!skip)
                        {
                            it = new IndexTool(settings, filename, IndexType.ffmsindex);
                            it.OnInfoMsg += new ExternalTool.InfoEventHandler(IndexMsg);
                            it.OnLogMsg += new ExternalTool.LogEventHandler(IndexMsg);
                            it.Start();
                            it.WaitForExit();
                            if (it == null || !it.Successfull)
                            {
                                logWindow.MessageCrop(Global.Res("ErrorIndex"));
                                return false;
                            }
                        }
                    }

                    if (settings.cropInput == 2 || settings.encodeInput == 2)
                    {
                        string output = System.IO.Path.ChangeExtension(filename, "dgi");

                        bool skip = false;
                        if (File.Exists(output) && !settings.deleteIndex)
                        {
                            skip = true;
                        }
                        if (!skip)
                        {
                            it = new IndexTool(settings, filename, IndexType.dgindex);
                            it.OnInfoMsg += new ExternalTool.InfoEventHandler(IndexMsg);
                            it.OnLogMsg += new ExternalTool.LogEventHandler(IndexMsg);
                            it.Start();
                            it.WaitForExit();
                            if (!it.Successfull)
                            {
                                logWindow.MessageCrop(Global.Res("ErrorIndex"));
                                return false;
                            }
                        }
                    }

                    if (avo == null || !avo.disableAutocrop)
                    {
                        if (settings.cropInput == 0)
                        {
                            File.WriteAllText(settings.workingDir + "\\" + settings.filePrefix + "_cropTemp.avs",
                                "DirectShowSource(\"" + filename + "\")");
                        }
                        else if (settings.cropInput == 1)
                        {
                            string data = "";
                            string dlldir = System.IO.Path.GetDirectoryName(settings.ffmsindexPath);
                            if (File.Exists(dlldir + "\\ffms2.dll"))
                            {
                                data = "LoadPlugin(\"" + dlldir + "\\ffms2.dll" + "\")\r\n";
                            }
                            data += "FFVideoSource(\"" + filename + "\")";
                            File.WriteAllText(settings.workingDir + "\\" + settings.filePrefix + "_cropTemp.avs", data);
                        }
                        else if (settings.cropInput == 2)
                        {
                            string output = System.IO.Path.ChangeExtension(filename, "dgi");
                            string data = "";
                            string dlldir = System.IO.Path.GetDirectoryName(settings.dgindexnvPath);
                            if (File.Exists(dlldir + "\\DGDecodeNV.dll"))
                            {
                                data = "LoadPlugin(\"" + dlldir + "\\DGDecodeNV.dll" + "\")\r\n";
                            }
                            data += "DGSource(\"" + output + "\")";
                            File.WriteAllText(settings.workingDir + "\\" + settings.filePrefix + "_cropTemp.avs", data);
                        }
                        else if (settings.cropInput == 3)
                        {
                            string data = "";
                            string dlldir = System.IO.Path.GetDirectoryName(settings.lsmashPath);
                            if (File.Exists(dlldir + "\\LSMASHSource.dll"))
                            {
                                data = "LoadPlugin(\"" + dlldir + "\\LSMASHSource.dll" + "\")\r\n";
                            }
                            data += "LWLibavVideoSource(\"" + filename + "\")";
                            File.WriteAllText(settings.workingDir + "\\" + settings.filePrefix + "_cropTemp.avs", data);
                        }
                        logWindow.MessageCrop(Global.Res("InfoStartCrop"));

                        AutoCrop ac = new AutoCrop(settings.workingDir + "\\" + settings.filePrefix + "_cropTemp.avs", settings, ref cropInfo);
                        
                        if (cropInfo.error)
                        {
                            logWindow.MessageCrop(Global.Res("ErrorException") + " " + cropInfo.errorStr);
                            return false;
                        }

                        if (settings.minimizeAutocrop && !settings.manualCrop)
                        {
                            ac.WindowState = FormWindowState.Minimized;
                        }

                        ac.NrFrames = settings.nrFrames;
                        ac.BlackValue = settings.blackValue;
                        ac.ShowDialog();

                        if (cropInfo.error)
                        {
                            logWindow.MessageCrop(Global.Res("ErrorException") + " " + cropInfo.errorStr);
                            return false;
                        }
                        cropInfo.resizeMethod = settings.resizeMethod;
                    }
                    else
                    {
                        cropInfo.border = avo.manualBorders;
                        cropInfo.borderBottom = avo.borderBottom;
                        cropInfo.borderTop = avo.borderTop;
                        cropInfo.resize = avo.manualResize;
                        cropInfo.resizeX = avo.resizeX;
                        cropInfo.resizeY = avo.resizeY;
                        cropInfo.resizeMethod = avo.resizeMethod;
                        cropInfo.error = false;
                        if (avo.manualCrop)
                        {
                            cropInfo.cropBottom = avo.cropBottom;
                            cropInfo.cropTop = avo.cropTop;
                        }
                        else
                        {
                            cropInfo.cropBottom = 0;
                            cropInfo.cropTop = 0;
                        }
                    }

                    logWindow.MessageCrop("");
                    logWindow.MessageCrop(Global.ResFormat("InfoCropTop", cropInfo.cropTop));
                    logWindow.MessageCrop(Global.ResFormat("InfoCropBottom", cropInfo.cropBottom));
                    if (cropInfo.border)
                    {
                        logWindow.MessageCrop(Global.ResFormat("InfoBorderTop", cropInfo.borderTop));
                        logWindow.MessageCrop(Global.ResFormat("InfoBorderBottom", cropInfo.borderBottom));
                    }
                    if (cropInfo.resize)
                    {
                        logWindow.MessageCrop(Global.ResFormat("InfoResize", cropInfo.resizeX, cropInfo.resizeY));
                    }
                }
                foreach (StreamInfo si in demuxedStreamList.streams)
                {
                    if (si.streamType == StreamType.Video)
                    {
                        if (si.extraFileInfo.GetType() != typeof(VideoFileInfo))
                        {
                            si.extraFileInfo = new VideoFileInfo();
                        }
                        
                        ((VideoFileInfo)si.extraFileInfo).fps = fps;
                        ((VideoFileInfo)si.extraFileInfo).length = length;
                        if (frames != "")
                        {
                            ((VideoFileInfo)si.extraFileInfo).frames = frames;
                        }
                        ((VideoFileInfo)si.extraFileInfo).cropInfo = new CropInfo(cropInfo);
                    }
                }

                DoPlugin(PluginType.AfterAutoCrop);

                TitleInfo.SaveStreamInfoFile(demuxedStreamList, settings.workingDir + "\\" + settings.filePrefix + "_streamInfo.xml");
                demuxedStreamsWindow.UpdateDemuxedStreams();
                return true;
            }
            catch (Exception ex)
            {
                logWindow.MessageCrop(Global.Res("ErrorException") + " " + ex.Message);
                return false;
            }
            finally
            {

            }
        }
        public TimeSpan GetRunTime(string filename)
        {
            MediaInfoLib.MediaInfo mediaInfo = null;
            try
            {
                mediaInfo = new MediaInfoLib.MediaInfo();
                _logger.Trace("Getting media info from {0}", filename);

                mediaInfo.Option("ParseSpeed", "0.2");
                int open = mediaInfo.Open(filename);

                if (open != 0)
                {
                    int runTime;
                    Int32.TryParse(mediaInfo.Get(StreamKind.General, 0, "PlayTime"), out runTime);

                    mediaInfo.Close();
                    return TimeSpan.FromMilliseconds(runTime);
                }
            }
            catch (Exception ex)
            {
                _logger.ErrorException("Unable to parse media info from file: " + filename, ex);
            }
            finally
            {
                if (mediaInfo != null)
                {
                    mediaInfo.Close();
                }
            }

            return new TimeSpan();
        }
        public virtual Int32 GetRunTime(string filename)
        {
            var mediaInfo = new MediaInfo();

            try
            {
                logger.Trace("Getting media info from {0}", filename);

                mediaInfo.Option("ParseSpeed", "0.2");
                int open = mediaInfo.Open(filename);

                if (open != 0)
                {
                    int runTime;
                    Int32.TryParse(mediaInfo.Get(StreamKind.General, 0, "PlayTime"), out runTime);

                    mediaInfo.Close();
                    return runTime / 1000; //Convert to seconds
                }
            }
            catch (Exception ex)
            {
                logger.ErrorException("Unable to parse media info from file: " + filename, ex);
                mediaInfo.Close();
            }

            return 0;
        }
        private MediaInfoData GetMediaInfo(string location, MediaType mediaType)
        {
            Logger.ReportInfo("Getting media info from " + location);
            MediaInfoLib.MediaInfo mediaInfo = new MediaInfoLib.MediaInfo();
            mediaInfo.Option("ParseSpeed", "0.2");
            int i = mediaInfo.Open(location);
            MediaInfoData mediaInfoData = null;
            if (i != 0)
            {
                string subtitles = mediaInfo.Get(StreamKind.General, 0, "Text_Language_List");
                string scanType = mediaInfo.Get(StreamKind.Video, 0, "ScanType");
                int width;
                Int32.TryParse(mediaInfo.Get(StreamKind.Video, 0, "Width"), out width);
                int height;
                Int32.TryParse(mediaInfo.Get(StreamKind.Video, 0, "Height"), out height);
                int videoBitRate;
                Int32.TryParse(mediaInfo.Get(StreamKind.Video, 0, "BitRate"), out videoBitRate);

                int audioBitRate;
                string aBitRate = mediaInfo.Get(StreamKind.Audio, 0, "BitRate");
                int ABindex = aBitRate.IndexOf(" /");
                if (ABindex > 0)
                    aBitRate = aBitRate.Remove(ABindex);
                Int32.TryParse(aBitRate, out audioBitRate);

                int runTime;
                Int32.TryParse(mediaInfo.Get(StreamKind.General, 0, "PlayTime"), out runTime);
                int streamCount;
                Int32.TryParse(mediaInfo.Get(StreamKind.Audio, 0, "StreamCount"), out streamCount);

                string audioChannels = mediaInfo.Get(StreamKind.Audio, 0, "Channel(s)");
                int ACindex = audioChannels.IndexOf(" /");
                if (ACindex > 0)
                    audioChannels = audioChannels.Remove(ACindex);

                string audioLanguages = mediaInfo.Get(StreamKind.General, 0, "Audio_Language_List");

                string videoFrameRate = mediaInfo.Get(StreamKind.Video, 0, "FrameRate");

                string audioProfile = mediaInfo.Get(StreamKind.Audio, 0, "Format_Profile");
                int APindex = audioProfile.IndexOf(" /");
                if (APindex > 0)
                    audioProfile = audioProfile.Remove(APindex);

                mediaInfoData = new MediaInfoData
                {
                    PluginData = new MediaInfoData.MIData()
                    {
                        VideoCodec = mediaInfo.Get(StreamKind.Video, 0, "Codec/String"),
                        VideoBitRate = videoBitRate,
                        //MI.Get(StreamKind.Video, 0, "DisplayAspectRatio")),
                        Height = height,
                        Width = width,
                        //MI.Get(StreamKind.Video, 0, "Duration/String3")),
                        AudioFormat = mediaInfo.Get(StreamKind.Audio, 0, "Format"),
                        AudioBitRate = audioBitRate,
                        RunTime = (runTime / 60000),
                        AudioStreamCount = streamCount,
                        AudioChannelCount = audioChannels.Trim(),
                        AudioProfile = audioProfile.Trim(),
                        VideoFPS = videoFrameRate,
                        AudioLanguages = audioLanguages,
                        Subtitles = subtitles,
                        ScanType = scanType
                    }
                };
            }
            else
            {
                Logger.ReportInfo("Could not extract media information from " + location);
            }
            if (mediaType == MediaType.DVD && i != 0)
            {
                mediaInfo.Close();
                location = location.Replace("0.IFO", "1.vob");
                Logger.ReportInfo("Getting additional media info from " + location);
                mediaInfo.Option("ParseSpeed", "0.0");
                i = mediaInfo.Open(location);
                if (i != 0)
                {
                    int videoBitRate;
                    Int32.TryParse(mediaInfo.Get(StreamKind.Video, 0, "BitRate"), out videoBitRate);

                    int audioBitRate;
                    string aBitRate = mediaInfo.Get(StreamKind.Audio, 0, "BitRate");
                    int ABindex = aBitRate.IndexOf(" /");
                    if (ABindex > 0)
                        aBitRate = aBitRate.Remove(ABindex);
                    Int32.TryParse(aBitRate, out audioBitRate);
                    string scanType = mediaInfo.Get(StreamKind.Video, 0, "ScanType");

                    mediaInfoData.PluginData.AudioBitRate = audioBitRate;
                    mediaInfoData.PluginData.VideoBitRate = videoBitRate;
                    mediaInfoData.PluginData.ScanType = scanType;
                }
                else
                {
                    Logger.ReportInfo("Could not extract additional media info from " + location);
                }
            }
            mediaInfo.Close();
            return mediaInfoData;
        }
Beispiel #9
0
        private bool ChaptersExist(String file)
        {
            MediaInfo info = new MediaInfo();
            info.Open(file);

            info.Option("Inform", "XML");
            info.Option("Complete");
            return info.Inform().Contains("<track type=\"Menu\"");
        }
Beispiel #10
0
        public MediaInfoModel GetMediaInfo(string filename)
        {
            if (!_diskProvider.FileExists(filename))
            {
                throw new FileNotFoundException("Media file does not exist: " + filename);
            }

            MediaInfoLib.MediaInfo mediaInfo = null;

            try
            {
                mediaInfo = new MediaInfoLib.MediaInfo();
                _logger.Debug("Getting media info from {0}", filename);

                mediaInfo.Option("ParseSpeed", "0.2");
                int open = mediaInfo.Open(filename);

                if (open != 0)
                {
                    int     width;
                    int     height;
                    int     videoBitRate;
                    int     audioBitRate;
                    int     audioRuntime;
                    int     videoRuntime;
                    int     generalRuntime;
                    int     streamCount;
                    int     audioChannels;
                    decimal videoFrameRate;

                    string subtitles = mediaInfo.Get(StreamKind.General, 0, "Text_Language_List");
                    string scanType  = mediaInfo.Get(StreamKind.Video, 0, "ScanType");
                    Int32.TryParse(mediaInfo.Get(StreamKind.Video, 0, "Width"), out width);
                    Int32.TryParse(mediaInfo.Get(StreamKind.Video, 0, "Height"), out height);
                    Int32.TryParse(mediaInfo.Get(StreamKind.Video, 0, "BitRate"), out videoBitRate);
                    Decimal.TryParse(mediaInfo.Get(StreamKind.Video, 0, "FrameRate"), out videoFrameRate);

                    //Runtime
                    Int32.TryParse(mediaInfo.Get(StreamKind.Video, 0, "PlayTime"), out videoRuntime);
                    Int32.TryParse(mediaInfo.Get(StreamKind.Audio, 0, "PlayTime"), out audioRuntime);
                    Int32.TryParse(mediaInfo.Get(StreamKind.General, 0, "PlayTime"), out generalRuntime);

                    string aBitRate = mediaInfo.Get(StreamKind.Audio, 0, "BitRate");
                    int    aBindex  = aBitRate.IndexOf(" /", StringComparison.InvariantCultureIgnoreCase);
                    if (aBindex > 0)
                    {
                        aBitRate = aBitRate.Remove(aBindex);
                    }

                    Int32.TryParse(aBitRate, out audioBitRate);
                    Int32.TryParse(mediaInfo.Get(StreamKind.Audio, 0, "StreamCount"), out streamCount);


                    string audioChannelsStr = mediaInfo.Get(StreamKind.Audio, 0, "Channel(s)");
                    int    aCindex          = audioChannelsStr.IndexOf(" /", StringComparison.InvariantCultureIgnoreCase);
                    if (aCindex > 0)
                    {
                        audioChannelsStr = audioChannelsStr.Remove(aCindex);
                    }

                    string audioLanguages = mediaInfo.Get(StreamKind.General, 0, "Audio_Language_List");
                    string audioProfile   = mediaInfo.Get(StreamKind.Audio, 0, "Format_Profile");

                    int aPindex = audioProfile.IndexOf(" /", StringComparison.InvariantCultureIgnoreCase);
                    if (aPindex > 0)
                    {
                        audioProfile = audioProfile.Remove(aPindex);
                    }

                    Int32.TryParse(audioChannelsStr, out audioChannels);
                    var mediaInfoModel = new MediaInfoModel
                    {
                        VideoCodec       = mediaInfo.Get(StreamKind.Video, 0, "Codec/String"),
                        VideoBitrate     = videoBitRate,
                        Height           = height,
                        Width            = width,
                        AudioFormat      = mediaInfo.Get(StreamKind.Audio, 0, "Format"),
                        AudioBitrate     = audioBitRate,
                        RunTime          = GetBestRuntime(audioRuntime, videoRuntime, generalRuntime),
                        AudioStreamCount = streamCount,
                        AudioChannels    = audioChannels,
                        AudioProfile     = audioProfile.Trim(),
                        VideoFps         = videoFrameRate,
                        AudioLanguages   = audioLanguages,
                        Subtitles        = subtitles,
                        ScanType         = scanType
                    };

                    return(mediaInfoModel);
                }
            }
            catch (DllNotFoundException ex)
            {
                _logger.ErrorException("mediainfo is required but was not found", ex);
                throw;
            }
            catch (Exception ex)
            {
                _logger.ErrorException("Unable to parse media info from file: " + filename, ex);
            }
            finally
            {
                if (mediaInfo != null)
                {
                    mediaInfo.Close();
                }
            }

            return(null);
        }
        static void Main(string[] Args)
        {
            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)
            {
                Console.Out.WriteLine("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";
            String File_Name;
            if (Args.Length == 0)
                File_Name = "Example.ogg";
            else
                File_Name = Args[0];
            MI.Open(File_Name);

            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();

            //Displaying the text
            Console.Out.WriteLine(ToDisplay);

            Console.Out.WriteLine("Press a key to close window.");
            Console.Read();
        }
 public StreamInfo()
 {
     try
     {
         MediaInfo MI = new MediaInfo();
         version = MI.Option("Info_Version", "0.7.0.0;MediaInfoDLL_Example_CS;0.7.0.0");
         if (version.Length == 0)
         {
             //Logging.Writer(System.Diagnostics.TraceEventType.Warning, "MediaInfoDLL Errer");
             return;
         }
     }
     catch (Exception ex) { /*Logging.Writer(ex);*/ }
 }
 public StreamInfo(string fullpath)
 {
     try
     {
         MediaInfo MI = new MediaInfo();
         version = MI.Option("Info_Version", "0.7.0.0;MediaInfoDLL_Example_CS;0.7.0.0");
         if (version.Length == 0)
         {
             //Logging.Writer(System.Diagnostics.TraceEventType.Warning, "MediaInfoDLL Errer");
             return;
         }
         if (MI.Open(fullpath) == 0)
         {
             //Logging.Writer(System.Diagnostics.TraceEventType.Warning, "MediaInfoDLL File Open Errer File=" + fullpath);
             return;
         }
         MI.Option("Complete", "1");
         string result = MI.Inform();
         MI.Option("Inform", "General;%Duration/String3%");
         result = MI.Inform();
         if (result.Length <= 0)
         {
             //Logging.Writer(System.Diagnostics.TraceEventType.Warning, "MediaInfoDLL Get Duration");
             return;
         }
         int Hour = int.Parse(result.Substring(0, 2));
         int Minute = int.Parse(result.Substring(3, 2));
         int Second = int.Parse(result.Substring(6, 2));
         this.duration = new TimeSpan(Hour, Minute, Second);
         this.bitrate = long.Parse(MI.Get(StreamKind.General, 0, "OverallBitRate"));
         int count = MI.Count_Get(StreamKind.Video);
         for (int i = 0; i < count; i++)
         {
             Video video = new Video(MI, i);
             this.Videos.Add(video);
         }
         count = MI.Count_Get(StreamKind.Audio);
         for (int i = 0; i < count; i++)
         {
             Audio audio = new Audio(MI,i);
             this.Audios.Add(audio);
         }
     }
     catch (Exception ex) { /*Logging.Writer(ex);*/ }
 }
        public MediaInfoModel GetMediaInfo(string filename)
        {
            if (!_diskProvider.FileExists(filename))
                throw new FileNotFoundException("Media file does not exist: " + filename);

            MediaInfoLib.MediaInfo mediaInfo = null;

            try
            {
                mediaInfo = new MediaInfoLib.MediaInfo();
                _logger.Trace("Getting media info from {0}", filename);

                mediaInfo.Option("ParseSpeed", "0.2");
                int open = mediaInfo.Open(filename);

                if (open != 0)
                {
                    int width;
                    int height;
                    int videoBitRate;
                    int audioBitRate;
                    int audioRuntime;
                    int videoRuntime;
                    int generalRuntime;
                    int streamCount;
                    int audioChannels;
                    decimal videoFrameRate;

                    string subtitles = mediaInfo.Get(StreamKind.General, 0, "Text_Language_List");
                    string scanType = mediaInfo.Get(StreamKind.Video, 0, "ScanType");
                    Int32.TryParse(mediaInfo.Get(StreamKind.Video, 0, "Width"), out width);
                    Int32.TryParse(mediaInfo.Get(StreamKind.Video, 0, "Height"), out height);
                    Int32.TryParse(mediaInfo.Get(StreamKind.Video, 0, "BitRate"), out videoBitRate);
                    Decimal.TryParse(mediaInfo.Get(StreamKind.Video, 0, "FrameRate"), out videoFrameRate);

                    //Runtime
                    Int32.TryParse(mediaInfo.Get(StreamKind.Video, 0, "PlayTime"), out videoRuntime);
                    Int32.TryParse(mediaInfo.Get(StreamKind.Audio, 0, "PlayTime"), out audioRuntime);
                    Int32.TryParse(mediaInfo.Get(StreamKind.General, 0, "PlayTime"), out generalRuntime);

                    string aBitRate = mediaInfo.Get(StreamKind.Audio, 0, "BitRate");
                    int aBindex = aBitRate.IndexOf(" /", StringComparison.InvariantCultureIgnoreCase);
                    if (aBindex > 0)
                        aBitRate = aBitRate.Remove(aBindex);

                    Int32.TryParse(aBitRate, out audioBitRate);
                    Int32.TryParse(mediaInfo.Get(StreamKind.Audio, 0, "StreamCount"), out streamCount);
                    

                    string audioChannelsStr = mediaInfo.Get(StreamKind.Audio, 0, "Channel(s)");
                    int aCindex = audioChannelsStr.IndexOf(" /", StringComparison.InvariantCultureIgnoreCase);
                    if (aCindex > 0)
                        audioChannelsStr = audioChannelsStr.Remove(aCindex);

                    string audioLanguages = mediaInfo.Get(StreamKind.General, 0, "Audio_Language_List");
                    string audioProfile = mediaInfo.Get(StreamKind.Audio, 0, "Format_Profile");

                    int aPindex = audioProfile.IndexOf(" /", StringComparison.InvariantCultureIgnoreCase);
                    if (aPindex > 0)
                        audioProfile = audioProfile.Remove(aPindex);

                    Int32.TryParse(audioChannelsStr, out audioChannels);
                    var mediaInfoModel = new MediaInfoModel
                                                {
                                                    VideoCodec = mediaInfo.Get(StreamKind.Video, 0, "Codec/String"),
                                                    VideoBitrate = videoBitRate,
                                                    Height = height,
                                                    Width = width,
                                                    AudioFormat = mediaInfo.Get(StreamKind.Audio, 0, "Format"),
                                                    AudioBitrate = audioBitRate,
                                                    RunTime = GetBestRuntime(audioRuntime, videoRuntime, generalRuntime),
                                                    AudioStreamCount = streamCount,
                                                    AudioChannels = audioChannels,
                                                    AudioProfile = audioProfile.Trim(),
                                                    VideoFps = videoFrameRate,
                                                    AudioLanguages = audioLanguages,
                                                    Subtitles = subtitles,
                                                    ScanType = scanType
                                                };

                    return mediaInfoModel;
                }
            }
            catch (DllNotFoundException ex)
            {
                _logger.ErrorException("mediainfo is required but was not found", ex);
                throw;
            }
            catch (Exception ex)
            {
                _logger.ErrorException("Unable to parse media info from file: " + filename, ex);
            }
            finally
            {
                if (mediaInfo != null)
                {
                    mediaInfo.Close();
                }
            }

            return null;
        }
        private bool ChaptersExist(String file)
        {
            WriteLog("Checking if file contains chapters: " + file);
            var info = new MediaInfo();
            info.Open(file);

            info.Option("Inform", "XML");
            info.Option("Complete");
            if (info.Inform().Contains("<track type=\"Menu\""))
            {
                WriteLog("It contains chapters");
                return true;
            }

            WriteLog("It didn't contain chapters");
            return false;
        }
        private void CheckInputFile(Media mf)
        {
            using (FFMpegWrapper ff = new FFMpegWrapper(mf.FullPath))
            {
                inputFileStreams = ff.GetStreamInfo();
            }

            MediaInfo mi = new MediaInfo();
            try
            {
                mi.Open(mf.FullPath);
                mi.Option("Complete");
                string miOutput = mi.Inform();

                Regex format_lxf = new Regex("Format\\s*:\\s*LXF");
                if (format_lxf.Match(miOutput).Success)
                {
                    string[] miOutputLines = miOutput.Split('\n');
                    Regex vitc = new Regex("ATC_VITC");
                    Regex re = new Regex("Time code of first frame\\s*:[\\s]\\d{2}:\\d{2}:\\d{2}:\\d{2}");
                    for (int i = 0; i < miOutputLines.Length; i++)
                    {
                        if (vitc.Match(miOutputLines[i]).Success && i >= 1)
                        {
                            Match m_tcs = re.Match(miOutputLines[i - 1]);
                            if (m_tcs.Success)
                            {
                                Regex reg_tc = new Regex("\\d{2}:\\d{2}:\\d{2}:\\d{2}");
                                Match m_tc = reg_tc.Match(m_tcs.Value);
                                if (m_tc.Success)
                                {
                                    DestMedia.TCStart = reg_tc.Match(m_tc.Value).Value.SMPTETimecodeToTimeSpan();
                                    if (DestMedia.TCPlay == TimeSpan.Zero)
                                        DestMedia.TCPlay = DestMedia.TCStart;
                                    break;
                                }
                            }
                        }
                    }
                }

                Regex format_mxf = new Regex(@"Format\s*:\s*MXF");
                if (format_mxf.Match(miOutput).Success)
                {
                    string[] miOutputLines = miOutput.Split('\n');
                    Regex mxf_tc = new Regex(@"MXF TC");
                    Regex re = new Regex(@"Time code of first frame\s*:[\s]\d{2}:\d{2}:\d{2}:\d{2}");
                    for (int i = 0; i < miOutputLines.Length; i++)
                    {
                        Match mxf_match = mxf_tc.Match(miOutputLines[i]);
                        if (mxf_match.Success && i < miOutputLines.Length - 1)
                        {
                            Regex reg_tc = new Regex(@"\d{2}:\d{2}:\d{2}:\d{2}");
                            Match m_tc = re.Match(miOutputLines[i + 1]);
                            if (m_tc.Success)
                            {
                                DestMedia.TCStart = reg_tc.Match(m_tc.Value).Value.SMPTETimecodeToTimeSpan();
                                if (DestMedia.TCPlay == TimeSpan.Zero)
                                    DestMedia.TCPlay = DestMedia.TCStart;
                                break;
                            }
                        }
                    }
                }
            }
            finally
            {
                mi.Close();
            }
        }
        public static void FileMediaInformation()
        {
            Console.WriteLine("Introduzca una ruta:");
            FilePath = Console.ReadLine();

            if (File.Exists(FilePath))
            {
                MediaInfo _info = new MediaInfo();

                Console.WriteLine(_info.Option("Info_Version", "0.7.0.0;MediaInfoDLL_Example_CS;0.7.0.0"));

                _info.Open(FilePath);

                //informacion del archivo, tipo de archivo, filesize, etc...
                _info.Option("Complete");
                Console.WriteLine(_info.Inform());

                Console.WriteLine("\n----------------------------------");

                //file size
                _info.Option("Inform", "General;File size is %FileSize% bytes");
                Console.WriteLine(_info.Inform());

                Console.WriteLine("\n----------------------------------");

                Console.WriteLine(_info.Count_Get(StreamKind.Audio));

                Console.WriteLine("\n----------------------------------");

                Console.WriteLine(_info.Get(StreamKind.General, 0, "AudioCount"));

                Console.WriteLine("\n----------------------------------");

                Console.WriteLine(_info.Get(StreamKind.Audio, 0, "StreamCount"));

                Console.WriteLine("\n----------------------------------");

                //tipo de formato del archivo
                Console.WriteLine(_info.Get(StreamKind.General, 0, "Format"));

                Console.WriteLine("\n----------------------------------");

                Console.WriteLine(_info.Get(StreamKind.Audio, 0, "BitRate"));

                Console.WriteLine("\n----------------------------------");

                Console.WriteLine(ExampleWithStream());

                do
                {
                    Console.WriteLine("\n----------------------------------");
                    Console.WriteLine("Introduzca un comando para StreamKind.Audio:");
                    Console.WriteLine(_info.Get(StreamKind.Audio, 0, Console.ReadLine()));
                    Console.WriteLine("\n----------------------------------");
                    Console.WriteLine("\nDesea Continuar? Y/N");
                }
                while (Console.ReadLine().ToUpper() != "N");

                Console.ReadLine();
            }
            else {
                Console.WriteLine("El archivo no existe. Desea Continuar? Y/N");
                if (Console.ReadLine().ToUpper() != "N")
                {
                    FileMediaInformation();
                }
            }
        }
        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";

            Crc16Ccitt A=new Crc16Ccitt(InitialCrcValue.Zeros);
            byte[] B = { 0x84, 0x00, 0x00, 0x00, 0x6B, 0x00, 0x00, 0x00, 0x67, 0x1F, 0x20, 0x00, 0x00, 0x62, 0x0C, 0x9B, 0x35, 0x35, 0x38, 0x3B, 0x34, 0x31, 0x36, 0x20, 0x56, 0x9B, 0x38, 0x31, 0x3B, 0x33, 0x32, 0x20, 0x5F, 0x90, 0x6F, 0x90, 0x20, 0x41, 0x90, 0x7E, 0x9B, 0x31, 0x3B, 0x30, 0x30, 0x30, 0x30, 0x20, 0x63, 0x9B, 0x30, 0x20, 0x58, 0x1C, 0x40, 0x40, 0x1C, 0x46, 0x40, 0x90, 0x20, 0x40, 0x90, 0x50, 0xC9, 0xB3, 0xC7, 0x89, 0x20, 0x1D, 0x61, 0x1B, 0x7E, 0xC0, 0xA4, 0xE9, 0xF3, 0xC1, 0xF3, 0x8A, 0x24, 0x72, 0x21, 0x29, 0x88, 0x1C, 0x4F, 0x41, 0x89, 0xE1, 0xAD, 0xB7, 0xB3, 0x8A, 0x21, 0x29, 0x89, 0x20, 0x8A, 0x21, 0x44, 0x89, 0xA4, 0xF3, 0xBF, 0xF9, 0xCD, 0xC3, 0xC8, 0x8A, 0x21, 0x29 };
            ushort C=A.ComputeChecksum(B);

            //Displaying the text
            richTextBox1.Text = ToDisplay;
        }
Beispiel #19
0
        /// <summary>
        /// Reads a media file and creates a MediaFile object
        /// </summary>
        /// <param name="fp">File Path of the Media File</param>
        /// <returns>MediaFile object</returns>
        public void ReadFile()
        {
            this.Source = Source;

            if (File.Exists(FilePath))
            {
                MediaInfoLib.MediaInfo MI = null;
                try
                {
                    Debug.WriteLine("Loading MediaInfo.dll");
                    MI = new MediaInfoLib.MediaInfo();
                    Debug.WriteLine("Loaded MediaInfo.dll");
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex.ToString());
                }

                if (MI != null)
                {
                    Debug.WriteLine(string.Format("MediaInfo Opening {0}", FilePath));
                    MI.Open(FilePath);
                    Debug.WriteLine(string.Format("MediaInfo Opened {0}", FilePath));

                    MI.Option("Complete");
                    this.Summary = MI.Inform();
                    MI.Option("Complete", "1");
                    this.SummaryComplete = MI.Inform();

                    if (App.IsUNIX)
                    {
                        Debug.WriteLine(string.Format("MediaInfo Summary Length: {0}", this.Summary.Length.ToString()));
                        Debug.WriteLine(string.Format("MediaInfo Summary: {0}", this.Summary));
                    }

                    // Format Info
                    if (string.IsNullOrEmpty(this.Format))
                    {
                        this.Format = MI.Get(StreamKind.General, 0, "Format");
                    }
                    this.FormatInfo = MI.Get(StreamKind.General, 0, "Format/Info");

                    // this.FileName = mMI.Get(0, 0, "FileName");
                    if (this.FileSize == 0)
                    {
                        double sz;
                        double.TryParse(MI.Get(0, 0, "FileSize"), out sz);
                        this.FileSize = sz;
                    }
                    if (string.IsNullOrEmpty(this.FileSizeString))
                    {
                        this.FileSizeString = string.Format("{0} MiB", (this.FileSize / 1024.0 / 1024.0).ToString("0.00"));
                    }

                    // Duration
                    if (string.IsNullOrEmpty(this.DurationString2))
                    {
                        this.DurationString2 = MI.Get(0, 0, "Duration/String2");
                    }

                    if (this.Duration == 0.0)
                    {
                        double dura = 0.0;
                        double.TryParse(MI.Get(0, 0, "Duration"), out dura);
                        this.Duration        = dura;
                        this.SegmentDuration = dura;
                    }

                    if (string.IsNullOrEmpty(this.DurationString3))
                    {
                        this.DurationString3 = MI.Get(0, 0, "Duration/String3");
                    }

                    this.BitrateOverall     = MI.Get(StreamKind.General, 0, "OverallBitRate/String");
                    this.EncodedApplication = MI.Get(StreamKind.General, 0, "Encoded_Application");
                    this.EncodedDate        = MI.Get(StreamKind.General, 0, "Encoded_Date");

                    if (string.IsNullOrEmpty(this.Subtitles))
                    {
                        StringBuilder sbSubs = new StringBuilder();

                        int subCount = 0;
                        int.TryParse(MI.Get(StreamKind.Text, 0, "StreamCount"), out subCount);

                        if (subCount > 0)
                        {
                            StringBuilder sbLang = new StringBuilder();
                            for (int i = 0; i < subCount; i++)
                            {
                                string lang = MI.Get(StreamKind.Text, i, "Language/String");
                                if (!string.IsNullOrEmpty(lang))
                                {
                                    sbLang.Append(lang);
                                    if (i < subCount - 1)
                                    {
                                        sbLang.Append(", ");
                                    }
                                }
                            }
                            if (!string.IsNullOrEmpty(sbLang.ToString()))
                            {
                                sbSubs.Append(sbLang.ToString());
                            }
                            else
                            {
                                sbSubs.Append("N/A");
                            }
                        }
                        else
                        {
                            sbSubs.Append("None");
                        }

                        this.Subtitles = sbSubs.ToString();
                    }

                    //*********************
                    //* Video
                    //*********************

                    int videoCount;
                    int.TryParse(MI.Get(StreamKind.General, 0, "VideoCount"), out videoCount);
                    this.HasVideo = videoCount > 0;

                    this.Video.Format        = MI.Get(StreamKind.Video, 0, "Format");
                    this.Video.FormatVersion = MI.Get(StreamKind.Video, 0, "Format_Version");

                    if (Path.GetExtension(this.FilePath).ToLower().Equals(".mkv"))
                    {
                        this.Video.Codec = MI.Get(StreamKind.Video, 0, "Encoded_Library");
                    }
                    this.Video.EncodedLibrarySettings = MI.Get(StreamKind.Video, 0, "Encoded_Library_Settings");
                    this.Video.DisplayAspectRatio     = MI.Get(StreamKind.Video, 0, "DisplayAspectRatio/String");

                    if (string.IsNullOrEmpty(this.Video.Codec))
                    {
                        this.Video.Codec = MI.Get(StreamKind.Video, 0, "CodecID/Hint");
                    }
                    if (string.IsNullOrEmpty(this.Video.Codec))
                    {
                        this.Video.Codec = MI.Get(StreamKind.Video, 0, "CodecID");
                    }

                    this.Video.Bitrate  = MI.Get(StreamKind.Video, 0, "BitRate/String");
                    this.Video.Standard = MI.Get(StreamKind.Video, 0, "Standard");
                    ;
                    this.Video.FrameRate          = MI.Get(StreamKind.Video, 0, "FrameRate/String");
                    this.Video.ScanType           = MI.Get(StreamKind.Video, 0, "ScanType/String");
                    this.Video.Height             = MI.Get(StreamKind.Video, 0, "Height");
                    this.Video.Width              = MI.Get(StreamKind.Video, 0, "Width");
                    this.Video.Resolution         = string.Format("{0}x{1}", this.Video.Width, this.Video.Height);
                    this.Video.BitsPerPixelXFrame = MI.Get(StreamKind.Video, 0, "Bits-(Pixel*Frame)");

                    //*********************
                    //* Audio
                    //*********************
                    int audioCount;
                    int.TryParse(MI.Get(StreamKind.General, 0, "AudioCount"), out audioCount);
                    this.HasAudio = audioCount > 0;

                    for (int id = 0; id < audioCount; id++)
                    {
                        AudioInfo ai = new AudioInfo(id);
                        ai.Format        = MI.Get(StreamKind.Audio, id, "Format");
                        ai.FormatVersion = MI.Get(StreamKind.Audio, 0, "Format_Version");
                        ai.FormatProfile = MI.Get(StreamKind.Audio, 0, "Format_Profile");

                        ai.Codec = MI.Get(StreamKind.Audio, 0, "CodecID/Hint");
                        if (string.IsNullOrEmpty(ai.Codec))
                        {
                            ai.Codec = MI.Get(StreamKind.Audio, 0, "CodecID/Info");
                        }
                        if (string.IsNullOrEmpty(ai.Codec))
                        {
                            ai.Codec = MI.Get(StreamKind.Audio, 0, "CodecID");
                        }

                        ai.Bitrate     = MI.Get(StreamKind.Audio, id, "BitRate/String");
                        ai.BitrateMode = MI.Get(StreamKind.Audio, id, "BitRate_Mode/String");

                        ai.Channels     = MI.Get(StreamKind.Audio, id, "Channel(s)/String");
                        ai.SamplingRate = MI.Get(StreamKind.Audio, id, "SamplingRate/String");
                        ai.Resolution   = MI.Get(StreamKind.Audio, id, "Resolution/String");

                        this.Audio.Add(ai);
                    }

                    MI.Close();

                    //// Analyse Audio only files using TagLib

                    //if (this.HasAudio && !this.HasVideo)
                    //{
                    //    TagLib.File f = TagLib.File.Create(this.FilePath);
                    //    this.TagLibFile = f;
                    //}
                }
            }
        }
        private MediaInfoData GetMediaInfo(string location, MediaType mediaType)
        {
            Logger.ReportInfo("Getting media info from " + location);
            MediaInfoLib.MediaInfo mediaInfo = new MediaInfoLib.MediaInfo();
            mediaInfo.Option("ParseSpeed", "0.2");
            int           i             = mediaInfo.Open(location);
            MediaInfoData mediaInfoData = null;

            if (i != 0)
            {
                string subtitles = mediaInfo.Get(StreamKind.General, 0, "Text_Language_List");
                string scanType  = mediaInfo.Get(StreamKind.Video, 0, "ScanType");
                int    width;
                Int32.TryParse(mediaInfo.Get(StreamKind.Video, 0, "Width"), out width);
                int height;
                Int32.TryParse(mediaInfo.Get(StreamKind.Video, 0, "Height"), out height);
                int videoBitRate;
                Int32.TryParse(mediaInfo.Get(StreamKind.Video, 0, "BitRate"), out videoBitRate);

                int    audioBitRate;
                string aBitRate = mediaInfo.Get(StreamKind.Audio, 0, "BitRate");
                int    ABindex  = aBitRate.IndexOf(" /");
                if (ABindex > 0)
                {
                    aBitRate = aBitRate.Remove(ABindex);
                }
                Int32.TryParse(aBitRate, out audioBitRate);

                int runTime;
                Int32.TryParse(mediaInfo.Get(StreamKind.General, 0, "PlayTime"), out runTime);
                int streamCount;
                Int32.TryParse(mediaInfo.Get(StreamKind.Audio, 0, "StreamCount"), out streamCount);

                string audioChannels = mediaInfo.Get(StreamKind.Audio, 0, "Channel(s)");
                int    ACindex       = audioChannels.IndexOf(" /");
                if (ACindex > 0)
                {
                    audioChannels = audioChannels.Remove(ACindex);
                }

                string audioLanguages = mediaInfo.Get(StreamKind.General, 0, "Audio_Language_List");

                string videoFrameRate = mediaInfo.Get(StreamKind.Video, 0, "FrameRate");

                string audioProfile = mediaInfo.Get(StreamKind.Audio, 0, "Format_Profile");
                int    APindex      = audioProfile.IndexOf(" /");
                if (APindex > 0)
                {
                    audioProfile = audioProfile.Remove(APindex);
                }



                mediaInfoData = new MediaInfoData
                {
                    PluginData = new MediaInfoData.MIData()
                    {
                        VideoCodec   = mediaInfo.Get(StreamKind.Video, 0, "Codec/String"),
                        VideoBitRate = videoBitRate,
                        //MI.Get(StreamKind.Video, 0, "DisplayAspectRatio")),
                        Height = height,
                        Width  = width,
                        //MI.Get(StreamKind.Video, 0, "Duration/String3")),
                        AudioFormat       = mediaInfo.Get(StreamKind.Audio, 0, "Format"),
                        AudioBitRate      = audioBitRate,
                        RunTime           = (runTime / 60000),
                        AudioStreamCount  = streamCount,
                        AudioChannelCount = audioChannels.Trim(),
                        AudioProfile      = audioProfile.Trim(),
                        VideoFPS          = videoFrameRate,
                        AudioLanguages    = audioLanguages,
                        Subtitles         = subtitles,
                        ScanType          = scanType
                    }
                };
            }
            else
            {
                Logger.ReportInfo("Could not extract media information from " + location);
            }
            if (mediaType == MediaType.DVD && i != 0)
            {
                mediaInfo.Close();
                location = location.Replace("0.IFO", "1.vob");
                Logger.ReportInfo("Getting additional media info from " + location);
                mediaInfo.Option("ParseSpeed", "0.0");
                i = mediaInfo.Open(location);
                if (i != 0)
                {
                    int videoBitRate;
                    Int32.TryParse(mediaInfo.Get(StreamKind.Video, 0, "BitRate"), out videoBitRate);

                    int    audioBitRate;
                    string aBitRate = mediaInfo.Get(StreamKind.Audio, 0, "BitRate");
                    int    ABindex  = aBitRate.IndexOf(" /");
                    if (ABindex > 0)
                    {
                        aBitRate = aBitRate.Remove(ABindex);
                    }
                    Int32.TryParse(aBitRate, out audioBitRate);
                    string scanType = mediaInfo.Get(StreamKind.Video, 0, "ScanType");

                    mediaInfoData.PluginData.AudioBitRate = audioBitRate;
                    mediaInfoData.PluginData.VideoBitRate = videoBitRate;
                    mediaInfoData.PluginData.ScanType     = scanType;
                }
                else
                {
                    Logger.ReportInfo("Could not extract additional media info from " + location);
                }
            }
            mediaInfo.Close();
            return(mediaInfoData);
        }
 private Int32 GetDuration(string location)
 {
     MediaInfoLib.MediaInfo mediaInfo = new MediaInfoLib.MediaInfo();
     mediaInfo.Option("ParseSpeed", "0.3");
     int i = mediaInfo.Open(location);
     int runTime = 0;
     if (i != 0)
     {
         Int32.TryParse(mediaInfo.Get(StreamKind.General, 0, "PlayTime"), out runTime);
     }
     mediaInfo.Close();
     return runTime;
 }
Beispiel #22
0
        /// <summary>
        /// Reads a media file and creates a MediaFile object
        /// </summary>
        /// <param name="fp">File Path of the Media File</param>
        /// <returns>MediaFile object</returns>
        public void ReadFile()
        {
            this.Source = Source;

            if (File.Exists(FilePath))
            {
                //*********************
                //* General
                //*********************

                //System.Debug.WriteLine("Current Dir1: " + System.Environment.CurrentDirectory);
                //System.Environment.CurrentDirectory = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
                //System.Debug.WriteLine("Current Dir2: " + System.Environment.CurrentDirectory);

                MediaInfoLib.MediaInfo MI = null;
                try
                {
                    Debug.WriteLine("Loading MediaInfo.dll");
                    MI = new MediaInfoLib.MediaInfo();
                    Debug.WriteLine("Loaded MediaInfo.dll");
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex.ToString());
                }

                if (MI != null)
                {
                    Debug.WriteLine(string.Format("MediaInfo Opening {0}", FilePath));
                    MI.Open(FilePath);
                    Debug.WriteLine(string.Format("MediaInfo Opened {0}", FilePath));
                    MI.Option("Complete");
                    this.Summary = MI.Inform();
                    MI.Option("Complete", "1");
                    this.SummaryComplete = MI.Inform();

                    if (Program.IsUNIX)
                    {
                        Debug.WriteLine(string.Format("MediaInfo Summary Length: {0}", this.Summary.Length.ToString()));
                        Debug.WriteLine(string.Format("MediaInfo Summary: {0}", this.Summary));
                    }

                    // Format Info
                    if (string.IsNullOrEmpty(this.Format))
                        this.Format = MI.Get(StreamKind.General, 0, "Format");
                    this.FormatInfo = MI.Get(StreamKind.General, 0, "Format/Info");

                    // this.FileName = mMI.Get(0, 0, "FileName");
                    if (0 == this.FileSize)
                    {
                        double sz;
                        double.TryParse(MI.Get(0, 0, "FileSize"), out sz);
                        this.FileSize = sz;
                    }
                    if (string.IsNullOrEmpty(this.FileSizeString))
                    {
                        this.FileSizeString = string.Format("{0} MiB", (this.FileSize / 1024.0 / 1024.0).ToString("0.00"));
                    }

                    // Duration
                    if (string.IsNullOrEmpty(this.DurationString2))
                        this.DurationString2 = MI.Get(0, 0, "Duration/String2");

                    if (this.Duration == 0.0)
                    {
                        double dura = 0.0;
                        double.TryParse(MI.Get(0, 0, "Duration"), out dura);
                        this.Duration = dura;
                        this.SegmentDuration = dura;
                    }

                    if (string.IsNullOrEmpty(this.DurationString3))
                        this.DurationString3 = MI.Get(0, 0, "Duration/String3");

                    this.BitrateOverall = MI.Get(StreamKind.General, 0, "OverallBitRate/String");
                    this.EncodedApplication = MI.Get(StreamKind.General, 0, "Encoded_Application");
                    this.EncodedDate = MI.Get(StreamKind.General, 0, "Encoded_Date");

                    if (string.IsNullOrEmpty(this.Subtitles))
                    {
                        StringBuilder sbSubs = new StringBuilder();

                        int subCount = 0;
                        int.TryParse(MI.Get(StreamKind.Text, 0, "StreamCount"), out subCount);

                        if (subCount > 0)
                        {
                            StringBuilder sbLang = new StringBuilder();
                            for (int i = 0; i < subCount; i++)
                            {
                                string lang = MI.Get(StreamKind.Text, i, "Language/String");
                                if (!string.IsNullOrEmpty(lang))
                                {
                                    // System.Windows.Forms.MessageBox.Show(lang);
                                    sbLang.Append(lang);
                                    if (i < subCount - 1)
                                        sbLang.Append(", ");
                                }
                            }
                            if (!string.IsNullOrEmpty(sbLang.ToString()))
                            {
                                sbSubs.Append(sbLang.ToString());
                            }
                            else
                            {
                                sbSubs.Append("N/A");
                            }
                        }
                        else
                        {
                            sbSubs.Append("None");
                        }

                        this.Subtitles = sbSubs.ToString();
                    }

                    //*********************
                    //* Video
                    //*********************

                    int videoCount;
                    int.TryParse(MI.Get(StreamKind.General, 0, "VideoCount"), out videoCount);
                    this.HasVideo = videoCount > 0;

                    this.Video.Format = MI.Get(StreamKind.Video, 0, "Format");
                    this.Video.FormatVersion = MI.Get(StreamKind.Video, 0, "Format_Version");

                    if (Path.GetExtension(this.FilePath).ToLower().Equals(".mkv"))
                    {
                        this.Video.Codec = MI.Get(StreamKind.Video, 0, "Encoded_Library");
                    }
                    this.Video.EncodedLibrarySettings = MI.Get(StreamKind.Video, 0, "Encoded_Library_Settings");
                    this.Video.DisplayAspectRatio = MI.Get(StreamKind.Video, 0, "DisplayAspectRatio/String");

                    if (string.IsNullOrEmpty(this.Video.Codec))
                        this.Video.Codec = MI.Get(StreamKind.Video, 0, "CodecID/Hint");
                    if (string.IsNullOrEmpty(this.Video.Codec))
                        this.Video.Codec = MI.Get(StreamKind.Video, 0, "CodecID");

                    this.Video.Bitrate = MI.Get(StreamKind.Video, 0, "BitRate/String");
                    this.Video.Standard = MI.Get(StreamKind.Video, 0, "Standard"); ;
                    this.Video.FrameRate = MI.Get(StreamKind.Video, 0, "FrameRate/String");
                    this.Video.ScanType = MI.Get(StreamKind.Video, 0, "ScanType/String");
                    this.Video.Height = MI.Get(StreamKind.Video, 0, "Height");
                    this.Video.Width = MI.Get(StreamKind.Video, 0, "Width");
                    this.Video.Resolution = string.Format("{0}x{1}", this.Video.Width, this.Video.Height);
                    this.Video.BitsPerPixelXFrame = MI.Get(StreamKind.Video, 0, "Bits-(Pixel*Frame)");

                    //*********************
                    //* Audio
                    //*********************
                    int audioCount;
                    int.TryParse(MI.Get(StreamKind.General, 0, "AudioCount"), out audioCount);
                    this.HasAudio = audioCount > 0;

                    for (int id = 0; id < audioCount; id++)
                    {
                        AudioInfo ai = new AudioInfo(id);
                        ai.Format = MI.Get(StreamKind.Audio, id, "Format");
                        ai.FormatVersion = MI.Get(StreamKind.Audio, 0, "Format_Version");
                        ai.FormatProfile = MI.Get(StreamKind.Audio, 0, "Format_Profile");

                        ai.Codec = MI.Get(StreamKind.Audio, 0, "CodecID/Hint");
                        if (string.IsNullOrEmpty(ai.Codec))
                            ai.Codec = MI.Get(StreamKind.Audio, 0, "CodecID/Info");
                        if (string.IsNullOrEmpty(ai.Codec))
                            ai.Codec = MI.Get(StreamKind.Audio, 0, "CodecID");

                        ai.Bitrate = MI.Get(StreamKind.Audio, id, "BitRate/String");
                        ai.BitrateMode = MI.Get(StreamKind.Audio, id, "BitRate_Mode/String");

                        ai.Channels = MI.Get(StreamKind.Audio, id, "Channel(s)/String");
                        ai.SamplingRate = MI.Get(StreamKind.Audio, id, "SamplingRate/String");
                        ai.Resolution = MI.Get(StreamKind.Audio, id, "Resolution/String");

                        this.Audio.Add(ai);
                    }

                    MI.Close();

                    //// Analyse Audio only files using TagLib

                    //if (this.HasAudio && !this.HasVideo)
                    //{
                    //    TagLib.File f = TagLib.File.Create(this.FilePath);
                    //    this.TagLibFile = f;
                    //}
                }
            }
        }
Beispiel #23
0
		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;
		}
Beispiel #24
0
        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)
                        {
                            skip = true;
                        }
                        if (!skip)
                        {
                            it            = new IndexTool(settings, filename, IndexType.ffmsindex);
                            it.OnInfoMsg += new ExternalTool.InfoEventHandler(IndexMsg);
                            it.OnLogMsg  += new ExternalTool.LogEventHandler(IndexMsg);
                            it.Start();
                            it.WaitForExit();
                            if (it == null || !it.Successfull)
                            {
                                logWindow.MessageCrop(Global.Res("ErrorIndex"));
                                return(false);
                            }
                        }
                    }

                    if (settings.cropInput == 2 || settings.encodeInput == 2)
                    {
                        string output = System.IO.Path.ChangeExtension(filename, "dgi");

                        bool skip = false;
                        if (File.Exists(output) && !settings.deleteIndex)
                        {
                            skip = true;
                        }
                        if (!skip)
                        {
                            it            = new IndexTool(settings, filename, IndexType.dgindex);
                            it.OnInfoMsg += new ExternalTool.InfoEventHandler(IndexMsg);
                            it.OnLogMsg  += new ExternalTool.LogEventHandler(IndexMsg);
                            it.Start();
                            it.WaitForExit();
                            if (!it.Successfull)
                            {
                                logWindow.MessageCrop(Global.Res("ErrorIndex"));
                                return(false);
                            }
                        }
                    }

                    if (avo == null || !avo.disableAutocrop)
                    {
                        if (settings.cropInput == 0)
                        {
                            File.WriteAllText(settings.workingDir + "\\" + settings.filePrefix + "_cropTemp.avs",
                                              "DirectShowSource(\"" + filename + "\")");
                        }
                        else if (settings.cropInput == 1)
                        {
                            string data   = "";
                            string dlldir = System.IO.Path.GetDirectoryName(settings.ffmsindexPath);
                            if (File.Exists(dlldir + "\\ffms2.dll"))
                            {
                                data = "LoadPlugin(\"" + dlldir + "\\ffms2.dll" + "\")\r\n";
                            }
                            data += "FFVideoSource(\"" + filename + "\")";
                            File.WriteAllText(settings.workingDir + "\\" + settings.filePrefix + "_cropTemp.avs", data);
                        }
                        else if (settings.cropInput == 2)
                        {
                            string output = System.IO.Path.ChangeExtension(filename, "dgi");
                            string data   = "";
                            string dlldir = System.IO.Path.GetDirectoryName(settings.dgindexnvPath);
                            if (File.Exists(dlldir + "\\DGDecodeNV.dll"))
                            {
                                data = "LoadPlugin(\"" + dlldir + "\\DGDecodeNV.dll" + "\")\r\n";
                            }
                            data += "DGSource(\"" + output + "\")";
                            File.WriteAllText(settings.workingDir + "\\" + settings.filePrefix + "_cropTemp.avs", data);
                        }
                        logWindow.MessageCrop(Global.Res("InfoStartCrop"));

                        AutoCrop ac = new AutoCrop(settings.workingDir + "\\" + settings.filePrefix + "_cropTemp.avs", settings, ref cropInfo);

                        if (cropInfo.error)
                        {
                            logWindow.MessageCrop(Global.Res("ErrorException") + " " + cropInfo.errorStr);
                            return(false);
                        }

                        if (settings.minimizeAutocrop && !settings.manualCrop)
                        {
                            ac.WindowState = FormWindowState.Minimized;
                        }

                        ac.NrFrames   = settings.nrFrames;
                        ac.BlackValue = settings.blackValue;
                        ac.ShowDialog();

                        if (cropInfo.error)
                        {
                            logWindow.MessageCrop(Global.Res("ErrorException") + " " + cropInfo.errorStr);
                            return(false);
                        }
                        cropInfo.resizeMethod = settings.resizeMethod;
                    }
                    else
                    {
                        cropInfo.border       = avo.manualBorders;
                        cropInfo.borderBottom = avo.borderBottom;
                        cropInfo.borderTop    = avo.borderTop;
                        cropInfo.resize       = avo.manualResize;
                        cropInfo.resizeX      = avo.resizeX;
                        cropInfo.resizeY      = avo.resizeY;
                        cropInfo.resizeMethod = avo.resizeMethod;
                        cropInfo.error        = false;
                        if (avo.manualCrop)
                        {
                            cropInfo.cropBottom = avo.cropBottom;
                            cropInfo.cropTop    = avo.cropTop;
                        }
                        else
                        {
                            cropInfo.cropBottom = 0;
                            cropInfo.cropTop    = 0;
                        }
                    }

                    logWindow.MessageCrop("");
                    logWindow.MessageCrop(Global.ResFormat("InfoCropTop", cropInfo.cropTop));
                    logWindow.MessageCrop(Global.ResFormat("InfoCropBottom", cropInfo.cropBottom));
                    if (cropInfo.border)
                    {
                        logWindow.MessageCrop(Global.ResFormat("InfoBorderTop", cropInfo.borderTop));
                        logWindow.MessageCrop(Global.ResFormat("InfoBorderBottom", cropInfo.borderBottom));
                    }
                    if (cropInfo.resize)
                    {
                        logWindow.MessageCrop(Global.ResFormat("InfoResize", cropInfo.resizeX, cropInfo.resizeY));
                    }
                }
                foreach (StreamInfo si in demuxedStreamList.streams)
                {
                    if (si.streamType == StreamType.Video)
                    {
                        if (si.extraFileInfo.GetType() != typeof(VideoFileInfo))
                        {
                            si.extraFileInfo = new VideoFileInfo();
                        }

                        ((VideoFileInfo)si.extraFileInfo).fps    = fps;
                        ((VideoFileInfo)si.extraFileInfo).length = length;
                        ((VideoFileInfo)si.extraFileInfo).frames = frames;

                        ((VideoFileInfo)si.extraFileInfo).cropInfo = new CropInfo(cropInfo);
                    }
                }

                DoPlugin(PluginType.AfterAutoCrop);

                TitleInfo.SaveStreamInfoFile(demuxedStreamList, settings.workingDir + "\\" + settings.filePrefix + "_streamInfo.xml");
                demuxedStreamsWindow.UpdateDemuxedStreams();
                return(true);
            }
            catch (Exception ex)
            {
                logWindow.MessageCrop(Global.Res("ErrorException") + " " + ex.Message);
                return(false);
            }
            finally
            {
            }
        }