php flvNaopeng

WBOY
Release: 2016-07-21 15:36:28
Original
1158 people have browsed it

涶嶅埗浠g爜 浠g爜濡备笅:

銆€銆€function BigEndian2Int ($byte_word, $signed = false) {
銆€銆€$int_value = 0;
銆€銆€$byte_wordlen = strlen($byte_word);
銆€銆€for ($i = 0; $i < $byte_wordlen; $i++)
銆€銆€{
銆€銆€$int_value += ord($byte_word{$i}) * pow(256, ($byte_wordlen - 1 - $i));
銆€銆€}
銆€銆€if ($signed)
銆€銆€{
銆€銆€$sign_mask_bit = 0x80 << ( 8 * ($byte_wordlen - 1));
銆€銆€if ($int_value & $sign_mask_bit)
銆€銆€{
銆€銆€$int_value = 0 - ($int_value & ( $sign_mask_bit - 1));
銆€銆€}
銆€銆€}
銆€銆€return $int_value;
銆€銆€}
銆€銆€function getTime($name){
銆€銆€if(!file_exists($name)){
銆€銆€return;
銆€銆€}
銆€銆€$flv_data_length= filesize($name);
銆€銆€$fp = @fopen($name, 'rb');
銆€銆€$flv_header = fread($fp, 5);
銆€銆€fseek($fp, 5, SEEK_SET);
銆€銆€$frame_size_data_length =BigEndian2Int(fread($fp, 4));
銆€銆€$flv_header_frame_length = 9;銆€if ($frame_size_data_length > $flv_header_frame_length) {
銆€銆€fseek($fp, $frame_size_data_length - $flv_header_frame_length, SEEK_CUR);
銆€銆€}
銆€銆€$duration = 0;
銆€銆€while ((ftell($fp) + 1) < $flv_data_length) {
銆€銆€$this_tag_header = fread($fp, 16);
銆€銆€$data_length = BigEndian2Int(substr($this_tag_header, 5, 3));
銆€銆€$timestamp = BigEndian2Int(substr($this_tag_header, 8, 3)); = ftell($fp) - 1 + $data_length;
銆€銆€if ($timestamp > $duration) {
銆€銆€$duration = $timestamp;
銆€銆€}
銆€銆€fseek($fp, $next_offset, SEEK_SET);
銆€銆€}
銆€銆€fclose($fp);
銆€銆€return $duration;
銆€銆€}
銆€銆€function fn($time){
銆€銆€$num = $time;
銆€銆€$sec = intval($num / 1000);
銆€銆€$h = intval($sec / 3600);
銆€銆€$m = intval(($sec % 3600) / 60);
銆€銆€ $s = intval(($sec % 60 ));
銆€銆€$tm = $h . ':' . $m . ':' . $s ;
銆€銆€return $tm ;
銆€銆€}
醆€銆€echo getTime("27729.flv"); 236722); //鏄剧ず镞濞濙镙狠狠0:03:56
銆€銆€?>



http://www.bkjia.com/PHPjc/322136.html

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/322136.htmlTechArticle涶嶅埗浠g爜浠g爜濡备簅: ?php function BigEndian2Int($byte_word, $signed = false) { $int_value = 0; $byte_wordlen = strlen($byte_word); for ($i = 0; $i $byte_wordlen; $i++) { $in...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template