function genLocalStreamImage($stream_id, $req_time, $req_size)
 {
     global $mvLocalVideoPath, $mvStreamImageTable;
     //zsh edit
     return false;
     if (!$stream_id) {
         return false;
     }
     if (!$req_time) {
         $req_time = 0;
     }
     if (!$req_size) {
         $req_size = '320x240';
     }
     list($im_width, $im_height, $ext) = MV_StreamImage::getSizeType($req_size);
     if ($req_size == null) {
         $s = '';
     } else {
         $s = '_' . $im_width . 'x' . $im_height;
     }
     $img_dir = MV_StreamImage::getLocalImageDir($stream_id);
     $img_file = $img_dir . "/" . $req_time . $s . "." . $ext;
     $streampath = $mvLocalVideoPath . MV_StreamImage::getLocalStreamPath($stream_id);
     if (is_file($streampath)) {
         //check if the ffmpeg extension is installed:
         $extension = "ffmpeg";
         $extension_soname = $extension . "." . PHP_SHLIB_SUFFIX;
         $extension_fullname = PHP_EXTENSION_DIR . "/" . $extension_soname;
         // load extension
         if (!extension_loaded($extension)) {
             if (!dl($extension_soname)) {
                 return false;
             }
         }
         $mov = new ffmpeg_movie($streampath);
         $fps = $mov->getFrameRate();
         if ($req_time == 0) {
             $ff_frame = $mov->getFrame(1);
         } else {
             $ff_frame = $mov->getFrame($req_time * $fps);
         }
         if ($ff_frame) {
             $ff_frame->resize($im_width, $im_height);
             $gd_image = $ff_frame->toGDImage();
             if ($gd_image) {
                 if ($ext == 'png') {
                     imagepng($gd_image, $img_file);
                     imagedestroy($gd_image);
                 } else {
                     imagejpeg($gd_image, $img_file);
                     imagedestroy($gd_image);
                 }
             }
         }
         if (is_file($img_file) && ($req_size == '320x240' || $req_size == '')) {
             $insAry = array();
             $insAry[stream_id] = $stream_id;
             $insAry[time] = $req_time;
             $db =& wfGetDB(DB_WRITE);
             if ($db->insert($mvStreamImageTable, $insAry)) {
                 return $img_file;
             } else {
                 //probably error out before we get here
                 return false;
             }
         }
     }
     return $img_file;
 }
Пример #2
0
 function getEmbedVideoHtml($options = array())
 {
     global $mvDefaultFlashQualityKey, $mvDefaultVideoQualityKey, $mvDefaultMP4QualityKey;
     //init options if unset:
     $vid_id = isset($options['id']) ? $options['id'] : '';
     $size = isset($options['size']) ? $options['size'] : '';
     $force_server = isset($options['force_server']) ? $options['force_server'] : '';
     $autoplay = isset($options['autoplay']) ? $options['autoplay'] : false;
     $showmeta = isset($options['showmeta']) ? $options['showmeta'] : false;
     $tag = 'video';
     if ($size == '') {
         global $mvDefaultVideoPlaybackRes;
         $size = $mvDefaultVideoPlaybackRes;
         list($vWidth, $vHeight) = explode('x', $size);
     } else {
         list($vWidth, $vHeight, $na) = MV_StreamImage::getSizeType($size);
     }
     $stream_web_url = $this->getWebStreamURL($mvDefaultVideoQualityKey);
     $flash_stream_url = $this->getWebStreamURL($mvDefaultFlashQualityKey);
     $mp4_stream_url = $this->getWebStreamURL($mvDefaultMP4QualityKey);
     // print "looking for q: $mvDefaultFlashQualityKey ";
     // print "FOUND: $flash_stream_url";
     $roe_url = $this->getROEURL();
     //if no urls available return missing:
     if (!$stream_web_url && !$flash_stream_url && !$mp4_stream_url) {
         return wfMsgWikiHtml('mv_error_stream_missing');
     }
     if ($stream_web_url || $flash_stream_url || $mp4_stream_url) {
         $o = '';
         /*if($this->dispVideoPlayerTime){
         			$o.='<span id="mv_videoPlayerTime">'.$this->getStartTime().' to '.
         					htmlspecialchars( $this->getEndTime() ) .
         				'</span>';
         		}*/
         $o .= '<' . htmlspecialchars($tag) . ' ';
         $o .= $vid_id == '' ? '' : ' id="' . htmlspecialchars($vid_id) . '" ';
         $o .= 'poster="' . $this->getStreamImageURL($size, null, $force_server) . '" ' . 'roe="' . $roe_url . '" ';
         $o .= $showmeta ? 'show_meta_link="true" ' : 'show_meta_link="false" ';
         $o .= $autoplay ? ' autoplay="true" ' : '';
         $o .= 'style="width:' . htmlspecialchars($vWidth) . 'px;height:' . htmlspecialchars($vHeight) . 'px" ' . 'controls="true" embed_link="true" >';
         if ($stream_web_url) {
             $o .= '<source timeFormat="anx" type="' . htmlspecialchars(MV_StreamFile::getTypeForQK($mvDefaultVideoQualityKey)) . '" src="' . $stream_web_url . '"></source>';
         }
         if ($flash_stream_url) {
             $o .= '<source timeFormat="anx" type="' . htmlspecialchars(MV_StreamFile::getTypeForQK($mvDefaultFlashQualityKey)) . '" src="' . $flash_stream_url . '"></source>';
         }
         if ($mp4_stream_url) {
             $o .= '<source timeFormat="mp4" type="' . htmlspecialchars(MV_StreamFile::getTypeForQK($mvDefaultMP4QualityKey)) . '" src="' . $mp4_stream_url . '"></source>';
         }
         $o .= '</' . htmlspecialchars($tag) . '>';
         return $o;
     }
 }