AydinAdn/MediaToolkit

ffmpeg Video FPS parse exception

Closed this issue · 1 comments

Hey there. I recently encountered an error when obtaining video metadata using the mediatoolkit. On occasion I'm getting a 'System.FormatException' (Input string was not in a correct format).

The FPS string ffmpeg is spitting out looks like ',1k tbr, 1k tbn....' (looks invalid; tough to deal with). The regex string doesn't like the string format it's being given. The error is happening around line 127 of RegexEngine.cs.

Thanks for the great project

I fixed it in RegexEngine.cs Line122~136, default return null.

        if (engine.InputFile.Metadata.VideoData == null)
            engine.InputFile.Metadata.VideoData = new Metadata.Video
            {
                Format = matchVideoFormatColorSize[1].ToString(),
                ColorModel = matchVideoFormatColorSize[2].ToString(),
                FrameSize = matchVideoFormatColorSize[3].ToString(),
                Fps =
                    string.IsNullOrEmpty(matchVideoFps[1].ToString())
                        ? null
                        : (double?)Convert.ToDouble(matchVideoFps[1].ToString(), new CultureInfo("en-US")),
                BitRateKbs =
                    (matchVideoBitRate.Success && !string.IsNullOrEmpty(matchVideoBitRate.Groups[1].ToString()))
                        ? (int?)Convert.ToInt32(matchVideoBitRate.Groups[1].ToString())
                        : null
            };