mirror of
https://github.com/HaschekSolutions/pictshare.git
synced 2025-11-14 04:04:01 +00:00
added ffmpeg binary location to config file so PictShare will run on a Raspberry Pi fixes #76
This commit is contained in:
@@ -26,3 +26,4 @@ services:
|
|||||||
- ALLOW_BLOATING=
|
- ALLOW_BLOATING=
|
||||||
- FORCE_DOMAIN=
|
- FORCE_DOMAIN=
|
||||||
- SHOW_ERRORS=
|
- SHOW_ERRORS=
|
||||||
|
- FFMPEG_BINARY=
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
spl_autoload_register('autoload');
|
spl_autoload_register('autoload');
|
||||||
|
|
||||||
|
if(!defined('FFMPEG_BINARY') || !FFMPEG_BINARY)
|
||||||
|
define('FFMPEG_BINARY',ROOT.DS.'bin'.DS.'ffmpeg');
|
||||||
|
|
||||||
function autoload($className)
|
function autoload($className)
|
||||||
{
|
{
|
||||||
if (file_exists(ROOT . DS . 'models' . DS . strtolower($className) . '.php'))
|
if (file_exists(ROOT . DS . 'models' . DS . strtolower($className) . '.php'))
|
||||||
|
|||||||
@@ -78,6 +78,7 @@ define('SHOW_ERRORS', false);
|
|||||||
//remove comments to use
|
//remove comments to use
|
||||||
|
|
||||||
/* BACKBLAZE B2 */
|
/* BACKBLAZE B2 */
|
||||||
|
//========
|
||||||
/* You can find your info here: https://secure.backblaze.com/b2_buckets.htm */
|
/* You can find your info here: https://secure.backblaze.com/b2_buckets.htm */
|
||||||
//define('BACKBLAZE',true); //true=>use backblaze false=>don't
|
//define('BACKBLAZE',true); //true=>use backblaze false=>don't
|
||||||
//define('BACKBLAZE_ID','');
|
//define('BACKBLAZE_ID','');
|
||||||
@@ -88,10 +89,21 @@ define('SHOW_ERRORS', false);
|
|||||||
//define('BACKBLAZE_AUTOUPLOAD', true); //if true, will upload images to backblaze when they are uploaded to pictshare
|
//define('BACKBLAZE_AUTOUPLOAD', true); //if true, will upload images to backblaze when they are uploaded to pictshare
|
||||||
//define('BACKBLAZE_AUTODELETE', true); //if true, will delete images from backblaze if they are deleted from pictshare
|
//define('BACKBLAZE_AUTODELETE', true); //if true, will delete images from backblaze if they are deleted from pictshare
|
||||||
|
|
||||||
|
|
||||||
|
//Backup Folder
|
||||||
|
//========
|
||||||
//If you have a NAS or some cifs or nfs mounted drive, you can specify this here as a folder
|
//If you have a NAS or some cifs or nfs mounted drive, you can specify this here as a folder
|
||||||
//if a requested hash is not found locally, its looked up on this location. This allows for mounted external spaces
|
//if a requested hash is not found locally, its looked up on this location. This allows for mounted external spaces
|
||||||
//or just backups on a second drive.
|
//or just backups on a second drive.
|
||||||
//Also new hashes will be uploaded there (just the originals, not resizes)
|
//Also new hashes will be uploaded/copied there (just the originals, not resizes)
|
||||||
//value should be a path **without tailing slash**!
|
//value should be a path **without tailing slash**!
|
||||||
|
|
||||||
define('ALT_FOLDER','/mnt');
|
//define('ALT_FOLDER','/mnt');
|
||||||
|
|
||||||
|
//FFMPEG
|
||||||
|
//========
|
||||||
|
//If you are using PictShare on some other machine than x64 linux (eg raspberry pi or windows) the builtin ffmpeg binary won't work
|
||||||
|
//this is why you can define an alternative path to the ffmpeg binary here.
|
||||||
|
|
||||||
|
//define('FFMPEG_BINARY','/usr/bin/ffmpeg');
|
||||||
|
|
||||||
|
|||||||
@@ -895,7 +895,7 @@ class PictshareModel extends Model
|
|||||||
{
|
{
|
||||||
$file = escapeshellarg($filename);
|
$file = escapeshellarg($filename);
|
||||||
$tmp = ROOT.DS.'tmp'.DS.md5(time()+rand(1,10000)).'.'.rand(1,10000).'.log';
|
$tmp = ROOT.DS.'tmp'.DS.md5(time()+rand(1,10000)).'.'.rand(1,10000).'.log';
|
||||||
$bin = escapeshellcmd(ROOT.DS.'bin'.DS.'ffmpeg');
|
$bin = escapeshellcmd(FFMPEG_BINARY);
|
||||||
|
|
||||||
$cmd = "$bin -i $file > $tmp 2>> $tmp";
|
$cmd = "$bin -i $file > $tmp 2>> $tmp";
|
||||||
|
|
||||||
@@ -921,7 +921,7 @@ class PictshareModel extends Model
|
|||||||
$file = ROOT.DS.'upload'.DS.$data['hash'].DS.$data['hash'];
|
$file = ROOT.DS.'upload'.DS.$data['hash'].DS.$data['hash'];
|
||||||
$file = escapeshellarg($file);
|
$file = escapeshellarg($file);
|
||||||
$tmp = '/dev/null';
|
$tmp = '/dev/null';
|
||||||
$bin = escapeshellcmd(ROOT.DS.'bin'.DS.'ffmpeg');
|
$bin = escapeshellcmd(FFMPEG_BINARY);
|
||||||
|
|
||||||
$size = $data['size'];
|
$size = $data['size'];
|
||||||
|
|
||||||
@@ -949,7 +949,7 @@ class PictshareModel extends Model
|
|||||||
|
|
||||||
function gifToMP4($gifpath,$target)
|
function gifToMP4($gifpath,$target)
|
||||||
{
|
{
|
||||||
$bin = escapeshellcmd(ROOT.DS.'bin'.DS.'ffmpeg');
|
$bin = escapeshellcmd(FFMPEG_BINARY);
|
||||||
$file = escapeshellarg($gifpath);
|
$file = escapeshellarg($gifpath);
|
||||||
|
|
||||||
if(!file_exists($target)) //simple caching.. have to think of something better
|
if(!file_exists($target)) //simple caching.. have to think of something better
|
||||||
@@ -964,7 +964,7 @@ class PictshareModel extends Model
|
|||||||
|
|
||||||
function saveAsMP4($source,$target)
|
function saveAsMP4($source,$target)
|
||||||
{
|
{
|
||||||
$bin = escapeshellcmd(ROOT.DS.'bin'.DS.'ffmpeg');
|
$bin = escapeshellcmd(FFMPEG_BINARY);
|
||||||
$source = escapeshellarg($source);
|
$source = escapeshellarg($source);
|
||||||
$target = escapeshellarg($target);
|
$target = escapeshellarg($target);
|
||||||
$h265 = "$bin -y -i $source -an -c:v libx264 -qp 0 -f mp4 $target";
|
$h265 = "$bin -y -i $source -an -c:v libx264 -qp 0 -f mp4 $target";
|
||||||
@@ -973,7 +973,7 @@ class PictshareModel extends Model
|
|||||||
|
|
||||||
function saveAsOGG($source,$target)
|
function saveAsOGG($source,$target)
|
||||||
{
|
{
|
||||||
$bin = escapeshellcmd(ROOT.DS.'bin'.DS.'ffmpeg');
|
$bin = escapeshellcmd(FFMPEG_BINARY);
|
||||||
$source = escapeshellarg($source);
|
$source = escapeshellarg($source);
|
||||||
$target = escapeshellarg($target);
|
$target = escapeshellarg($target);
|
||||||
$h265 = "$bin -y -i $source -vcodec libtheora -acodec libvorbis -qp 0 -f ogg $target";
|
$h265 = "$bin -y -i $source -vcodec libtheora -acodec libvorbis -qp 0 -f ogg $target";
|
||||||
@@ -983,7 +983,7 @@ class PictshareModel extends Model
|
|||||||
function saveAsWebm($source,$target)
|
function saveAsWebm($source,$target)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
$bin = escapeshellcmd(ROOT.DS.'bin'.DS.'ffmpeg');
|
$bin = escapeshellcmd(FFMPEG_BINARY);
|
||||||
$source = escapeshellarg($source);
|
$source = escapeshellarg($source);
|
||||||
$target = escapeshellarg($target);
|
$target = escapeshellarg($target);
|
||||||
$webm = "$bin -y -i $source -vcodec libvpx -acodec libvorbis -aq 5 -ac 2 -qmax 25 -f webm $target";
|
$webm = "$bin -y -i $source -vcodec libvpx -acodec libvorbis -aq 5 -ac 2 -qmax 25 -f webm $target";
|
||||||
@@ -992,7 +992,7 @@ class PictshareModel extends Model
|
|||||||
|
|
||||||
function saveFirstFrameOfMP4($path,$target)
|
function saveFirstFrameOfMP4($path,$target)
|
||||||
{
|
{
|
||||||
$bin = escapeshellcmd(ROOT.DS.'bin'.DS.'ffmpeg');
|
$bin = escapeshellcmd(FFMPEG_BINARY);
|
||||||
$file = escapeshellarg($path);
|
$file = escapeshellarg($path);
|
||||||
$cmd = "$bin -y -i $file -vframes 1 -f image2 $target";
|
$cmd = "$bin -y -i $file -vframes 1 -f image2 $target";
|
||||||
|
|
||||||
@@ -1003,7 +1003,7 @@ class PictshareModel extends Model
|
|||||||
function getSizeOfMP4($video)
|
function getSizeOfMP4($video)
|
||||||
{
|
{
|
||||||
$video = escapeshellarg($video);
|
$video = escapeshellarg($video);
|
||||||
$bin = escapeshellcmd(ROOT.DS.'bin'.DS.'ffmpeg');
|
$bin = escapeshellcmd(FFMPEG_BINARY);
|
||||||
$command = $bin . ' -i ' . $video . ' -vstats 2>&1';
|
$command = $bin . ' -i ' . $video . ' -vstats 2>&1';
|
||||||
$output = shell_exec($command);
|
$output = shell_exec($command);
|
||||||
|
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ if(in_array('altfolder',$argv) && defined('ALT_FOLDER') && ALT_FOLDER && is_dir(
|
|||||||
echo "\n [i] $filename is ..\t";
|
echo "\n [i] $filename is ..\t";
|
||||||
$valid = checkFileForValidMP4($img);
|
$valid = checkFileForValidMP4($img);
|
||||||
$tmp = ROOT.DS.'tmp'.DS.$hash;
|
$tmp = ROOT.DS.'tmp'.DS.$hash;
|
||||||
$cmd = ROOT.DS.'bin'.DS."ffmpeg -loglevel panic -y -i $img -vcodec libx264 -an -profile:v baseline -level 3.0 -pix_fmt yuv420p -vf \"scale=trunc(iw/2)*2:trunc(ih/2)*2\" $tmp && cp $tmp $img";
|
$cmd = FFMPEG_BINARY." -loglevel panic -y -i $img -vcodec libx264 -an -profile:v baseline -level 3.0 -pix_fmt yuv420p -vf \"scale=trunc(iw/2)*2:trunc(ih/2)*2\" $tmp && cp $tmp $img";
|
||||||
echo ($valid?'Valid'."\n":'Not valid => Converting..');
|
echo ($valid?'Valid'."\n":'Not valid => Converting..');
|
||||||
if(!$valid)
|
if(!$valid)
|
||||||
{
|
{
|
||||||
@@ -98,7 +98,7 @@ foreach($localfiles as $hash)
|
|||||||
{
|
{
|
||||||
$mp4 = $dir.$hash.DS.$hash;
|
$mp4 = $dir.$hash.DS.$hash;
|
||||||
$tmp = ROOT.DS.'tmp'.DS.$hash;
|
$tmp = ROOT.DS.'tmp'.DS.$hash;
|
||||||
$cmd = ROOT.DS.'bin'.DS."ffmpeg -loglevel panic -y -i $mp4 -vcodec libx264 -an -profile:v baseline -level 3.0 -pix_fmt yuv420p -vf \"scale=trunc(iw/2)*2:trunc(ih/2)*2\" $tmp && cp $tmp $mp4";
|
$cmd = FFMPEG_BINARY." -loglevel panic -y -i $mp4 -vcodec libx264 -an -profile:v baseline -level 3.0 -pix_fmt yuv420p -vf \"scale=trunc(iw/2)*2:trunc(ih/2)*2\" $tmp && cp $tmp $mp4";
|
||||||
echo " [i] Converting '$hash'";
|
echo " [i] Converting '$hash'";
|
||||||
system($cmd);
|
system($cmd);
|
||||||
if(defined('ALT_FOLDER') && ALT_FOLDER && is_dir(ALT_FOLDER))
|
if(defined('ALT_FOLDER') && ALT_FOLDER && is_dir(ALT_FOLDER))
|
||||||
@@ -110,7 +110,7 @@ foreach($localfiles as $hash)
|
|||||||
function checkFileForValidMP4($file)
|
function checkFileForValidMP4($file)
|
||||||
{
|
{
|
||||||
$hash = md5($file);
|
$hash = md5($file);
|
||||||
$cmd = ROOT.DS.'bin'.DS."ffmpeg -i $file -hide_banner 2> ".ROOT.DS.'tmp'.DS.$hash.'.txt';
|
$cmd = FFMPEG_BINARY." -i $file -hide_banner 2> ".ROOT.DS.'tmp'.DS.$hash.'.txt';
|
||||||
system($cmd);
|
system($cmd);
|
||||||
$results = file(ROOT.DS.'tmp'.DS.$hash.'.txt');
|
$results = file(ROOT.DS.'tmp'.DS.$hash.'.txt');
|
||||||
foreach($results as $l)
|
foreach($results as $l)
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ foreach($localfiles as $hash)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
echo " [OGG] User wants OGG. Will do.. ";
|
echo " [OGG] User wants OGG. Will do.. ";
|
||||||
$cmd = "../bin/ffmpeg -y -i $img -loglevel panic -vcodec libtheora -an $tmp && cp $tmp $ogg";
|
$cmd = FFMPEG_BINARY." -y -i $img -loglevel panic -vcodec libtheora -an $tmp && cp $tmp $ogg";
|
||||||
system($cmd);
|
system($cmd);
|
||||||
echo "done\n";
|
echo "done\n";
|
||||||
}
|
}
|
||||||
@@ -80,7 +80,7 @@ foreach($localfiles as $hash)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
echo " [WEBM] User wants WEBM. Will do.. ";
|
echo " [WEBM] User wants WEBM. Will do.. ";
|
||||||
$cmd = "../bin/ffmpeg -y -i $img -loglevel panic -c:v libvpx -crf 10 -b:v 1M $tmp && cp $tmp $webm";
|
$cmd = FFMPEG_BINARY." -y -i $img -loglevel panic -c:v libvpx -crf 10 -b:v 1M $tmp && cp $tmp $webm";
|
||||||
system($cmd);
|
system($cmd);
|
||||||
echo "done\n";
|
echo "done\n";
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user