+ $h = popen('ffprobe -show_streams -show_format "'
+ . $file_name . '" 2> /dev/null', 'r');
+
+ $tag = NULL;
+
+ while ( ($r = fgets($h, 512)) !== FALSE)
+ {
+ // Match tags.
+ if (preg_match('/^\[FORMAT\]/', $r))
+ {
+ $tag = 'FORMAT';
+ continue;
+ }
+ if (preg_match('/^\[STREAM\]/', $r))
+ {
+ $tag = 'STREAM';
+ continue;
+ }
+
+ if ($tag == 'FORMAT')
+ {
+ // Duration
+ if (preg_match('/^duration=/', $r))
+ $duration = format_duration(floatval(_parse_value($r)));
+
+ // Size
+ if (preg_match('/^size=/', $r))
+ $size = intval(_parse_value ($r));
+ }
+
+ if ($tag == 'STREAM')
+ {
+ // Width
+ if (preg_match('/^width=/', $r))
+ $width = intval(_parse_value($r));
+
+ // Height
+ if (preg_match('/^height=/', $r))
+ $height = intval(_parse_value($r));
+
+ // DAR
+ if (preg_match('/^display_aspect_ratio=/', $r))
+ $dar = _parse_value($r);
+ }
+ }
+
+ if (pclose($h) > 0)
+ return FALSE;
+
+ return array('width'=>$width, 'height'=>$height, 'dar'=>$dar,
+ 'duration'=>$duration, 'size'=>$size);