[add] detect duration, size of video

This commit is contained in:
Knah Tsaeb 2015-02-02 10:52:34 +01:00
parent 0a5b47e4d5
commit 4ce298f7f7
3 changed files with 43 additions and 5 deletions

19
bin/getInfo.sh Normal file
View File

@ -0,0 +1,19 @@
#!/bin/bash/
finalDest=/srv/http/sovigall.local/videos/
pageCache=/srv/http/sovigall.local/pagecache/
convertingTool=/usr/bin/ffmpeg
video=$1
path="$finalDest$2"
duration=$(eval $convertingTool -i "$path""$video.webm" 2>&1 | grep Duration | awk '{print $2}' | tr -d ,)
heure=$(echo $duration | cut -d":" -f1)
minute=$(echo $duration | cut -d":" -f2)
seconde=$(echo $duration | cut -d":" -f3 | cut -d"." -f1)
total=$(($heure*3600 + $minute*60 + $seconde))
sizeOfVideo=$(eval $convertingTool -i "$path""$video.webm" 2>&1 | grep "Stream #0:0" | awk '{print $6}' | tr -d ,)
#createDate=$(stat -c %y "$path""$video.webm" 2>&1 | awk '{print$1}' | sed 's/[\-]//g')
echo "$total"
echo "$sizeOfVideo"
#echo "$createDate"
rm $pageCache*.html 2> /dev/null

View File

@ -231,6 +231,7 @@ if (!empty($ci['ac']) && $ci['ac'] === 'view' && !empty($listCurrentFile)) {
<a href="?ac=view&amp;op=3&amp;bc=', $ci['bc'], '&amp;file=', $ci['file'], '&amp;token=', $token, '"><img src="images/useThumbnail.svg" alt="Use this thumbnail for folder thumbnail" title="Use this thumbnail for folder thumbnail"/></a>
<a href="?ac=view&amp;bc=', $ci['bc'], '&amp;file=', $ci['file'], '&amp;token=', $token, '&amp;op=confDelVideo"><img src="images/delete.svg" alt="Delete this video" title="Delete this video"/></a>
<a href="?ac=view&amp;bc=', $ci['bc'], '&amp;file=', $ci['file'], '&amp;token=', $token, '&amp;op=reDownload"><img src="images/reload.svg" alt="Re-download" title="Re-download"/></a>
<a href="?ac=view&amp;bc=', $ci['bc'], '&amp;file=', $ci['file'], '&amp;token=', $token, '&amp;op=updateInfo"><img src="images/reload.svg" alt="Re-download" title="Re-download"/></a>
</div>';
}
if ($GLOBALS['config']['DOWNLOAD_METHOD'] === 'xsendfile' || $GLOBALS['config']['DOWNLOAD_METHOD'] === 'php') {

View File

@ -277,9 +277,9 @@ function n_print($data, $name = '') {
<fieldset style="border: 1px solid orange; padding: 5px;color:#1E1915; background-color: #fff;">';
echo '
<legend style="border:1px solid orange;padding: 1px;background-color:#eee;color:orange;">
', basename($aBackTrace[0]['file']), ' ligne => ', $aBackTrace[0]['line'], '
', basename($aBackTrace[0]['file']), ' ligne => ', $aBackTrace[0]['line'], '
</legend>';
echo '<pre style="color:#1E1915;">', htmlentities(print_r($data, 1)), '</pre>';
echo '<pre style="color:#1E1915;">', htmlentities(print_r($data, 1)), '</pre>';
echo '
</fieldset>
<br />';
@ -365,7 +365,7 @@ function addVideo($ci, $fullListFile) {
file_put_contents($GLOBALS['config']['LISTFILE'], "<?php\n\$fullListFile=".var_export($fullListFile, true).";\n?>");
}
function redownloadVideo($bc, $file){
function redownloadVideo($bc, $file) {
$path = $GLOBALS['config']['VIDEODIR'].'/'.chunk_split($bc, 8, '/');
$pathAndFile = $path.$file;
rename($pathAndFile.'.hash', $GLOBALS['config']['TMPDIR'].'/'.$file.'.hash');
@ -513,6 +513,17 @@ function makeRss($breadcrumb, $fullListFile) {
exit();
}
function updateVideoInfo($dc,$file) {
$path = chunk_split($dc, 8, '/');
$file = escapeshellcmd($file);
$bc = escapeshellcmd($path);
exec('bash bin/getInfo.sh '.$file.' '.$bc, $result);
$jsonFile = json_decode(file_get_contents($GLOBALS['config']['VIDEODIR'].'/'.$path.$file.'.info.json'));
$jsonFile -> duration = $result[0];
$jsonFile -> format = '0 - '.$result[1];
file_put_contents($GLOBALS['config']['VIDEODIR'].'/'.$path.$file.'.info.json', json_encode($jsonFile));
}
function parseVideoDescription($file, $fullInfo = false) {
$value = json_decode(file_get_contents($file));
}
@ -521,7 +532,7 @@ function getVideoInfo($file, $dir, $fullListFile) {
$file = substr($file, 0, 10);
$postInfo = $fullListFile[$file];
$path = chunk_split($dir, 8, '/');
$descFile = glob($GLOBALS['config']['VIDEODIR']."/".$path.$file."*.json");
$descFile = glob($GLOBALS['config']['VIDEODIR'].'/'.$path.$file.'*.json');
$jsonInfo = json_decode(file_get_contents($descFile[0]));
$jsonSize = explode(' - ', htmlentities($jsonInfo -> format));
$jsonSize = explode('x', $jsonSize[1]);
@ -795,13 +806,20 @@ if (isset($ci['ac']) && !empty($ci['ac'])) {
}
cutVideo($ci['bc'], $ci['file']);
}
if ($ci['ac'] === 'view' && !empty($ci['op']) && $ci['op'] === 'reDownload') {
if ($ci['ac'] === 'view' && !empty($ci['op']) && $ci['op'] === 'reDownload') {
verifToken($ci['token']);
if (!isLog()) {
die('Tinker say : Blinded you, with Science! ');
}
reDownloadVideo($ci['bc'], $ci['file']);
}
if ($ci['ac'] === 'view' && !empty($ci['op']) && $ci['op'] === 'updateInfo') {
verifToken($ci['token']);
if (!isLog()) {
die('Tinker say : Blinded you, with Science! ');
}
updateVideoInfo($ci['bc'], $ci['file']);
}
if ($ci['ac'] === 'viewQueue' || $ci['ac'] === 'clearCache') {
verifToken($ci['token']);
if (!isLog()) {