> IIRC, ffmpeg is like this with everything going to stderr, making metadata parsing more difficult than it needs to be.
If you're trying to parse metadata, ffprobe has a set of options for structured output to stdout. Parsing this will be dramatically easier than whatever you're doing.
ffprobe -print_format json -show_format -show_streams example.mp4
(There's more -show_stuff options, but they're probably more detailed than you want. Run ffprobe --help for details.)