newCurrent(); ### HTTPs has to be enforced for opengraph sharing. if(strtoupper($URL->scheme) != 'HTTPS') $URL->setScheme('https'); $URL_PATH = array_shift( explode( 'og/'.$_GET['hash'], $URL->getFull() ) ); $GRAPH_URL = $URL_PATH.'og/'.$_GET['hash']; $CANON_URL = $URL_PATH.'file.php?hash='.$_GET['hash']; $BASIC_URL = $URL_PATH.$_GET['hash']; switch(strtoupper($fileExtension)) { case 'GIF': list($width, $height) = getimagesize($userPath); echo <<

END; break; case 'MP4': ### Create a thumbnail for the video. $file = strtolower( PseudoCrypt::hash( preg_replace( '/\D/', '', hash( 'sha512', $_GET['hash'] ) ), $config['ASSET_HASH_SIZE'] ) ); #### Build the user path. $userPath = join( DIRECTORY_SEPARATOR, array( $config['STORE_FOLDER'], $file ) ); ### Do not re-create the thumbnail if it already exists. if(!file_exists($userPath.'.'.'jpg')) { ### Extract thumbnail. $ffmpeg = FFMpeg\FFMpeg::create(); $video = $ffmpeg->open($CANON_URL); $frame = $video->frame( FFMpeg\Coordinate\TimeCode::fromSeconds( $config['VIDEO_PREVIEW_IMAGE_FRAME_SECOND'] ) ); $frame->save($userPath.'.'.'jpg'); } ### Get preview image size. list($imageWidth, $imageHeight) = getimagesize($userPath.'.'.'jpg'); ### Probe video for width and height. $ffprobe = FFMpeg\FFProbe::create(); $dimension = $ffprobe ->streams($CANON_URL) ->videos() ->first() ->getDimensions(); $videoDuration = round( $ffprobe ->streams($CANON_URL) ->videos() ->first() ->get('duration'), 0, PHP_ROUND_HALF_UP ); $videoWidth = $dimension->getWidth(); $videoHeight = $dimension->getHeight(); ### Build paths. $PREVIEW_IMAGE_URL = $URL_PATH.$file; $FLOW_PLAYER_VIDEO_URL = $URL_PATH.'flowplayer/flowplayer.swf?config={"clip":"'.$BASIC_URL.'"}'; $FLOW_PLAYER = $URL_PATH.'flowplayer/flowplayer.swf'; echo <<

END; break; }