I’m trying to grab the dimensions of a video from a string produced by ffmpeg’s output in .net, the dimensions i’m trying to obtain by regex are basically like this 1080×960 320×264 etc..
I’ve found many articles over this subject but none of this worked for me and sadly i’m no regex expert so i couldn’t edit their code.. The code that i’m trying to edit and can’t work looks like this if it gives you any insight;
Match c = Regex .Match (ffmpegOutputString,"\\s(\\d+)[xX](\\d+)\\s");
int w=int.Parse ( c.Groups[1].Value );
int h=int.Parse ( c.Groups[2].Value );
And the string i need to parse is this;
Video: wmv3 (Main), yuv420p, 360x264, 400 kb/s, PAR 1:1
With my basic regex knowledge it seems ok to me but it can’t grab anything, even i give it an empty string as an input the result is the same, the c.count is 1 and the value is empty string.
Any help is appreciated! Thanks.
With the string you need to parse, there is a comma directly after the
360x264. Your regex is"\\s(\\d+)[xX](\\d+)\\s". The\\smatches a whitespace character like a space or tab. Try removing the trailing\\sfrom the regex.