regex split and extract multiple parts from a string

Posted by nLL on Stack Overflow See other posts from Stack Overflow or by nLL
Published on 2010-05-15T17:17:36Z Indexed on 2010/05/15 17:54 UTC
Read the original article Hit count: 317

Filed under:
|
|

I am trying to extract some parts of the "Video:" line from below text.

Seems stream 0 codec frame rate differs from container frame rate: 30000.00 (300
00/1) -> 14.93 (1000/67)
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'C:\a.3gp':
  Metadata:
    major_brand     : 3gp5
    minor_version   : 0
    compatible_brands: 3gp5isom
  Duration: 00:00:45.82, start: 0.000000, bitrate: 357 kb/s
    Stream #0.0(und): Video: mpeg4, yuv420p, 352x276 [PAR 1:1 DAR 88:69], 344 kb
/s, 14.93 fps, 14.93 tbr, 90k tbn, 30k tbc
    Stream #0.1(und): Audio: aac, 16000 Hz, mono, s16, 11 kb/s
    Stream #0.2(und): Data: mp4s / 0x7334706D, 0 kb/s
    Stream #0.3(und): Data: mp4s / 0x7334706D, 0 kb/s*

This is an output from ffmpeg command line where i can get Video: part with

private string ExtractVideoFormat(string rawInfo)
{
    string v = string.Empty;
    Regex re = new Regex("[V|v]ideo:.*", RegexOptions.Compiled);
    Match m = re.Match(rawInfo);
    if (m.Success)
    {
        v = m.Value;
    }
    return v;
}

and result is

mpeg4, yuv420p, 352x276 [PAR 1:1 DAR 88:69], 344 kb

What i am trying to do is to somehow split that line and get

mpeg4
yuv420p
352x276 [PAR 1:1 DAR 88:69]
344 kb

assigned to different string objects instead of single

© Stack Overflow or respective owner

Related posts about c#

Related posts about regex