/graph.php |
@@ -7,6 +7,7 @@ |
require_once('php/pseudocrypt.php'); |
require_once('php/functions.php'); |
require_once('vendor/autoload.php'); |
require_once('vendor/php-ffmpeg/php-ffmpeg/src/FFMpeg/FFMpeg.php'); |
|
### Load configuration. |
$config = spyc_load_file('config.yaml'); |
@@ -66,7 +67,7 @@ |
|
$GRAPH_URL = $config['URL_PATH'].'og/'.$_GET['hash']; |
$CANON_URL = $config['URL_PATH'].'file.php?hash='.$_GET['hash']; |
$URL = $config['URL_PATH'].$_GET['hash']; |
$BASIC_URL = $config['URL_PATH'].$_GET['hash']; |
|
switch(strtoupper($fileExtension)) { |
case 'GIF': |
@@ -75,10 +76,10 @@ |
<html> |
<head> |
<meta property="og:site_name" content="Scratch Copy"> |
<meta property="og:url" content="$URL"> |
<meta property="og:url" content="$BASIC_URL"> |
<meta property="og:title" content="Scratch Copy"> |
<meta property="og:type" content="video.other"> |
<meta property="og:image" content="$URL"> |
<meta property="og:image" content="$BASIC_URL"> |
<meta property="og:image:width" content="$width"> |
<meta property="og:image:height" content="$height"> |
</head> |
@@ -93,6 +94,35 @@ |
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 |
) |
); |
|
### Extract thumbnail. |
$ffmpeg = FFMpeg\FFMpeg::create(); |
$video = $ffmpeg->open($CANON_URL); |
$frame = $video->frame(FFMpeg\Coordinate\TimeCode::fromSeconds(42)); |
$frame->save($userPath.'.'.'jpg'); |
echo <<<END |
<html> |
<head> |
@@ -102,9 +132,9 @@ |
|
<meta property="og:url" content="$GRAPH_URL"> |
|
<meta property="og:image" content="https://cpy.ro/img/blueprint.png"> |
<meta property="og:video" content='http://cpy.ro/flowplayer/flowplayer.swf?config={"clip":"$URL"}'> |
<meta property="og:video:secure_url" content='https://cpy.ro/flowplayer/flowplayer.swf?config={"clip":"$URL"}'> |
<meta property="og:image" content="https://cpy.ro/$file"> |
<meta property="og:video" content='http://cpy.ro/flowplayer/flowplayer.swf?config={"clip":"$BASIC_URL"}'> |
<meta property="og:video:secure_url" content='https://cpy.ro/flowplayer/flowplayer.swf?config={"clip":"$BASIC_URL"}'> |
<meta property="og:video:type" content="application/x-shockwave-flash"> |
<meta property="og:video:width" content="425"> |
<meta property="og:video:height" content="300"> |
@@ -112,7 +142,7 @@ |
|
<body> |
<p> |
<object width="425" height="300" id="Scratch Copy" name="Scratch Copy" data="https://cpy.ro/flowplayer/flowplayer.swf" type="application/x-shockwave-flash"><param name="movie" value="https://cpy.ro/flowplayer/flowplayer.swf" /><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="flashvars" value='config={"clip":"$URL"}' /></object> |
<object width="425" height="300" id="Scratch Copy" name="Scratch Copy" data="https://cpy.ro/flowplayer/flowplayer.swf" type="application/x-shockwave-flash"><param name="movie" value="https://cpy.ro/flowplayer/flowplayer.swf" /><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="flashvars" value='config={"clip":"$BASIC_URL"}' /></object> |
</p> |
</body> |
|