X-Git-Url: http://p2p-next.cs.pub.ro/gitweb/?a=blobdiff_plain;f=application%2Fhelpers%2Fav_info_helper.php;fp=application%2Fhelpers%2Fav_info_helper.php;h=013dab398efb9173300bdb5eeeae7dd5750d20ca;hb=e1f154780b5b004e047977b6582dd19bf85d4e4d;hp=0000000000000000000000000000000000000000;hpb=a34b84478af8de577afef1b762fc6861b2fd74e7;p=living-lab-site.git diff --git a/application/helpers/av_info_helper.php b/application/helpers/av_info_helper.php new file mode 100644 index 0000000..013dab3 --- /dev/null +++ b/application/helpers/av_info_helper.php @@ -0,0 +1,105 @@ +&1', 'r'); + + $r = fgets($h, 512); + $r = trim($r); + + if (pclose($h) > 0 || empty($r)) + return FALSE; + + return $r; +} + +/** + * Returns duration in hours, minutes and seconds for an audio/video file. + * + * @param string $file_name + * @return array an associative array with keys 'h', 'min', 's' + */ +function get_av_duration($file_name) +{ + $output = exec_mediainfo( + '--Inform="General;%Duration/String3%" "'. $file_name. '"'); + + if (!$output) + return FALSE; + + $toks = explode(':', $output); + $res['h'] = intval($toks[0]); + $res['min'] = intval($toks[1]); + $res['s'] = floatval($toks[2]); + + return $res; +} + +/** + * Returns video width size in pixels. + * + * @param string $file_name + * @return int + */ +function get_video_width($file_name) +{ + $output = exec_mediainfo( + '--Inform="Video;%Width%" "'. $file_name. '"'); + + if (!$output) + return FALSE; + + return intval($output); +} + +/** + * Returns video height size in pixels. + * + * @param string $file_name + * @return int + */ +function get_video_height($file_name) +{ + $output = exec_mediainfo( + '--Inform="Video;%Height%" "'. $file_name. '"'); + + if (!$output) + return FALSE; + + return intval($output); +} + +/** + * Returns Display Aspect Ration (DAR) of a video. + * + * @param string $file_name + * @return string a ratio represented a two integers separated by a colon + */ +function get_video_dar($file_name) +{ + $output = exec_mediainfo( + '--Inform="Video;%DisplayAspectRatio/String%" "'. $file_name. '"'); + + if (!$output) + return FALSE; + + return $output; +} + +/* End of file av_info_helper.php */ +/* Location: ./application/helpers/av_info_helper.php */ \ No newline at end of file