예제 #1
0
        private AvsFile(string script, bool parse)
        {
            try
            {
                this.enviroment = new AviSynthScriptEnvironment();
                this.clip = parse ? enviroment.ParseScript(script, AviSynthColorspace.RGB24) : enviroment.OpenScriptFile(script, AviSynthColorspace.RGB24);

                checked
                {
                    ulong width = (ulong)clip.VideoWidth;
                    ulong height = (ulong)clip.VideoHeight;
                    info = new MediaFileInfo(
                        clip.HasVideo, width, height,
                        new Dar(clip.GetIntVariable("MeGUI_darx", -1),
                              clip.GetIntVariable("MeGUI_dary", -1),
                              width, height),
                              (ulong)clip.num_frames,
                              ((double)clip.raten) / ((double)clip.rated),
                              (clip.SamplesCount != 0));
                }
            }
            catch (Exception)
            {
                cleanup();
                throw;
            }
        }
예제 #2
0
        private AvsFile(string script, bool parse)
        {
            try
            {
                this.enviroment = new AviSynthScriptEnvironment();
                this.clip       = parse ? enviroment.ParseScript(script, AviSynthColorspace.RGB24) : enviroment.OpenScriptFile(script, AviSynthColorspace.RGB24);

                checked
                {
                    ulong width  = (ulong)clip.VideoWidth;
                    ulong height = (ulong)clip.VideoHeight;
                    info = new MediaFileInfo(
                        clip.HasVideo, width, height,
                        new Dar(clip.GetIntVariable("MeGUI_darx", -1),
                                clip.GetIntVariable("MeGUI_dary", -1),
                                width, height),
                        (ulong)clip.num_frames,
                        ((double)clip.raten) / ((double)clip.rated),
                        (clip.SamplesCount != 0));
                }
            }
            catch (Exception)
            {
                cleanup();
                throw;
            }
        }
예제 #3
0
        /// <summary>
        /// reads the dgv file, which is essentially a text file
        /// </summary>
        private void readFileProperties()
        {
            info = reader.Info.Clone();
            Dar dar = new Dar(reader.Info.Width, reader.Info.Height);

            info.DAR = dar;
        }
예제 #4
0
        /// <summary>
        /// reads the d2v file, which is essentially a text file
        /// the first few lines contain the video properties in plain text and the
        /// last line contains the film percentage
        /// this method reads all this information and stores it internally, then
        /// closes the d2v file again
        /// </summary>
        private void readFileProperties()
        {
            info = reader.Info.Clone();
            Dar dar = Dar.A1x1;

            using (StreamReader sr = new StreamReader(fileName))
            {
                string line = sr.ReadLine();
                while ((line = sr.ReadLine()) != null)
                {
                    if (line.IndexOf("Aspect_Ratio") != -1)                     // this is the aspect ratio line
                    {
                        string ar = line.Substring(13);

                        if (reader.Info.Width == 720 && reader.Info.Height == 576)
                        {
                            if (ar.Equals("16:9"))
                            {
                                dar = Dar.ITU16x9PAL;
                            }
                            else if (ar.Equals("4:3"))
                            {
                                dar = Dar.ITU4x3PAL;
                            }
                        }
                        else if (reader.Info.Width == 720 && reader.Info.Height == 480)
                        {
                            if (ar.Equals("16:9"))
                            {
                                dar = Dar.ITU16x9NTSC;
                            }
                            else if (ar.Equals("4:3"))
                            {
                                dar = Dar.ITU4x3NTSC;
                            }
                        }
                    }
                    if (line.IndexOf("Field_Operation") != -1)
                    {
                        string fieldOp = line.Substring(16, 1);
                        this.fieldOperation = Int32.Parse(fieldOp);
                    }
                    if (line.IndexOf("FINISHED") != -1 && line.IndexOf("FILM") != -1)                     // dgindex now reports VIDEO % if it's > 50%
                    {
                        int    end        = line.IndexOf("%");
                        string percentage = line.Substring(10, end - 10);
                        this.filmPercentage = Double.Parse(percentage, System.Globalization.CultureInfo.InvariantCulture);
                    }
                }
            }
            info.DAR = dar;
        }
예제 #5
0
        /// <summary>
        /// reads the dga file, which is essentially a text file
        /// </summary>
        private void readFileProperties()
        {
            info = reader.Info.Clone();
            Dar dar = new Dar(reader.Info.Width, reader.Info.Height);

            info.DAR = dar;
        }
예제 #6
0
        /// <summary>
        /// reads the d2v file, which is essentially a text file
        //the first few lines contain the video properties in plain text and the
        /// last line contains the film percentage
        /// this method reads all this information and stores it internally, then 
        /// closes the d2v file again
        /// </summary>
        private void readFileProperties()
        {
            info = reader.Info.Clone();
            Dar dar = Dar.A1x1;
            using (StreamReader sr = new StreamReader(fileName))
            {
                string line = sr.ReadLine();
                while ((line = sr.ReadLine()) != null)
                {
                    if (line.IndexOf("Aspect_Ratio") != -1) // this is the aspect ratio line
                    {
                        string ar = line.Substring(13);

                        if (reader.Info.Width == 720 && reader.Info.Height == 480)
                        {
                            if (ar.Equals("16:9"))
                                dar = Dar.ITU16x9NTSC;
                            else if (ar.Equals("4:3"))
                                dar = Dar.ITU4x3NTSC;
                        }
                        else
                        {
                            if (ar.StartsWith("16:9"))
                                dar = Dar.ITU16x9PAL;
                            else if (ar.StartsWith("4:3"))  //AAA: I got 4:3,625 from DGIndex
                                dar = Dar.ITU4x3PAL;
                        }
                    }
                    if (line.IndexOf("Field_Operation") != -1)
                    {
                        string fieldOp = line.Substring(16, 1);
                        this.fieldOperation = Int32.Parse(fieldOp);
                    }
                    if (line.IndexOf("FINISHED") != -1 && line.IndexOf("FILM") != -1) // dgindex now reports VIDEO % if it's > 50%
                    {
                        int end = line.IndexOf("%");
                        string percentage = line.Substring(10, end - 10);
                        this.filmPercentage = Double.Parse(percentage, System.Globalization.CultureInfo.InvariantCulture);
                    }
                }
            }
            info.DAR = dar;
        }
예제 #7
0
        public MediaInfoFile(string file)
        {
            this.file = file;
            MediaInfo info = new MediaInfo(file);

            bool hasVideo = (info.Video.Count > 0);

            aCodecs       = new AudioCodec[info.Audio.Count];
            aBitrateModes = new BitrateManagementMode[info.Audio.Count];
            int i = 0;

            foreach (MediaInfoWrapper.AudioTrack track in info.Audio)
            {
                aCodecs[i] = getAudioCodec(track.Codec);
                if (track.BitRateMode == "VBR")
                {
                    aBitrateModes[i] = BitrateManagementMode.VBR;
                }
                else
                {
                    aBitrateModes[i] = BitrateManagementMode.CBR;
                }
            }
            if (info.General.Count < 1)
            {
                cType = null;
            }
            else
            {
                cType = getContainerType(info.General[0].Format, info.General[0].FormatString);
            }

            if (aCodecs.Length == 1)
            {
                aType = getAudioType(aCodecs[0], cType, file);
            }
            else
            {
                aType = null;
            }

            if (hasVideo)
            {
                MediaInfoWrapper.VideoTrack track = info.Video[0];
                checked
                {
                    ulong  width      = (ulong)easyParseInt(track.Width);
                    ulong  height     = (ulong)easyParseInt(track.Height);
                    ulong  frameCount = (ulong)easyParseInt(track.FrameCount);
                    double fps        = (easyParseDouble(track.FrameRate) ?? 25.0);
                    vCodec = getVideoCodec(track.Codec);
                    vType  = getVideoType(vCodec, cType, file);
                    Dar dar = new Dar((decimal?)easyParseDouble(track.AspectRatio), width, height);
                    this.info = new MediaFileInfo(hasVideo, width, height, dar, frameCount, fps, aCodecs.Length > 0);
                }
            }
            else
            {
                this.info = new MediaFileInfo(false, 0, 0, Dar.A1x1, 0, 0, aCodecs.Length > 0);
            }
        }