diff --git a/docker-compose.yml b/docker-compose.yml index 81f5af3..0e8b94b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -26,3 +26,4 @@ services: - ALLOW_BLOATING= - FORCE_DOMAIN= - SHOW_ERRORS= + - FFMPEG_BINARY= diff --git a/inc/core.php b/inc/core.php index 2c3ad40..5d02165 100644 --- a/inc/core.php +++ b/inc/core.php @@ -1,6 +1,9 @@ use backblaze false=>don't //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_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 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. -//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**! -define('ALT_FOLDER','/mnt'); \ No newline at end of file +//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'); + diff --git a/models/pictsharemodel.php b/models/pictsharemodel.php index da408c4..85430da 100644 --- a/models/pictsharemodel.php +++ b/models/pictsharemodel.php @@ -895,7 +895,7 @@ class PictshareModel extends Model { $file = escapeshellarg($filename); $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"; @@ -921,7 +921,7 @@ class PictshareModel extends Model $file = ROOT.DS.'upload'.DS.$data['hash'].DS.$data['hash']; $file = escapeshellarg($file); $tmp = '/dev/null'; - $bin = escapeshellcmd(ROOT.DS.'bin'.DS.'ffmpeg'); + $bin = escapeshellcmd(FFMPEG_BINARY); $size = $data['size']; @@ -949,7 +949,7 @@ class PictshareModel extends Model function gifToMP4($gifpath,$target) { - $bin = escapeshellcmd(ROOT.DS.'bin'.DS.'ffmpeg'); + $bin = escapeshellcmd(FFMPEG_BINARY); $file = escapeshellarg($gifpath); if(!file_exists($target)) //simple caching.. have to think of something better @@ -964,7 +964,7 @@ class PictshareModel extends Model function saveAsMP4($source,$target) { - $bin = escapeshellcmd(ROOT.DS.'bin'.DS.'ffmpeg'); + $bin = escapeshellcmd(FFMPEG_BINARY); $source = escapeshellarg($source); $target = escapeshellarg($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) { - $bin = escapeshellcmd(ROOT.DS.'bin'.DS.'ffmpeg'); + $bin = escapeshellcmd(FFMPEG_BINARY); $source = escapeshellarg($source); $target = escapeshellarg($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) { return false; - $bin = escapeshellcmd(ROOT.DS.'bin'.DS.'ffmpeg'); + $bin = escapeshellcmd(FFMPEG_BINARY); $source = escapeshellarg($source); $target = escapeshellarg($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) { - $bin = escapeshellcmd(ROOT.DS.'bin'.DS.'ffmpeg'); + $bin = escapeshellcmd(FFMPEG_BINARY); $file = escapeshellarg($path); $cmd = "$bin -y -i $file -vframes 1 -f image2 $target"; @@ -1003,7 +1003,7 @@ class PictshareModel extends Model function getSizeOfMP4($video) { $video = escapeshellarg($video); - $bin = escapeshellcmd(ROOT.DS.'bin'.DS.'ffmpeg'); + $bin = escapeshellcmd(FFMPEG_BINARY); $command = $bin . ' -i ' . $video . ' -vstats 2>&1'; $output = shell_exec($command); diff --git a/tools/re-encode_mp4.php b/tools/re-encode_mp4.php index 6be05b8..b6d0d28 100644 --- a/tools/re-encode_mp4.php +++ b/tools/re-encode_mp4.php @@ -48,7 +48,7 @@ if(in_array('altfolder',$argv) && defined('ALT_FOLDER') && ALT_FOLDER && is_dir( echo "\n [i] $filename is ..\t"; $valid = checkFileForValidMP4($img); $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..'); if(!$valid) { @@ -98,7 +98,7 @@ foreach($localfiles as $hash) { $mp4 = $dir.$hash.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'"; system($cmd); if(defined('ALT_FOLDER') && ALT_FOLDER && is_dir(ALT_FOLDER)) @@ -110,7 +110,7 @@ foreach($localfiles as $hash) function checkFileForValidMP4($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); $results = file(ROOT.DS.'tmp'.DS.$hash.'.txt'); foreach($results as $l) diff --git a/tools/render_webm_ogg.php b/tools/render_webm_ogg.php index 727aee6..fd3b49f 100644 --- a/tools/render_webm_ogg.php +++ b/tools/render_webm_ogg.php @@ -65,7 +65,7 @@ foreach($localfiles as $hash) else { 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); echo "done\n"; } @@ -80,7 +80,7 @@ foreach($localfiles as $hash) else { 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); echo "done\n"; }