Beispiel #1
0
        public static readonly Rational NtscFilm = _23_97Hz; // 24000/1001

        public static Rational Parse(string text)
        {
            if (text.IndexOf('/') > 0)
            {
                return(Rational.Parse(text));
            }

            // Aliases
            switch (text)
            {
            case "23.97": return(_23_97Hz);

            case "29.97": return(_29_97Hz);

            case "59.94": return(_59_94Hz);

            case "119.88": return(_119_88Hz);

            case "atsc": return(Atsc);

            case "film": return(Film);

            case "qpal": return(Pal);

            case "pal": return(Pal);

            case "ntsc": return(Ntsc);

            case "ntsc-film": return(NtscFilm);
            }

            // e.g. 30fps
            if (text.EndsWith("fps") && int.TryParse(text.Substring(0, text.Length - 3), out int fps))
            {
                return(new Rational(fps, 1));
            }
            // e.g. 30
            else if (int.TryParse(text.Substring(0, text.Length - 3), out fps))
            {
                return(new Rational(fps, 1));
            }

            throw new Exception("unknown frame rate:" + text);
        }
Beispiel #2
0
        public static TimeBase Parse(string text)
        {
            var rational = Rational.Parse(text);

            return(new TimeBase(rational.Numerator, rational.Denominator));
        }