mirror of
https://github.com/HaschekSolutions/pictshare.git
synced 2025-11-16 21:18:00 +00:00
added support for hashes via command argument
This commit is contained in:
@@ -25,7 +25,13 @@ $dir = ROOT.DS.'upload'.DS;
|
|||||||
$dh = opendir($dir);
|
$dh = opendir($dir);
|
||||||
$localfiles = array();
|
$localfiles = array();
|
||||||
|
|
||||||
if(in_array('noskip',$argv))
|
foreach($argv as $arg)
|
||||||
|
{
|
||||||
|
if($pm->isImage($arg) && $pm->isTypeAllowed(pathinfo($dir.$arg, PATHINFO_EXTENSION)) == 'mp4')
|
||||||
|
$localfiles[] = $arg;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(in_array('noskip',$argv) || in_array('force',$argv))
|
||||||
{
|
{
|
||||||
echo "Won't skip existing files\n\n";
|
echo "Won't skip existing files\n\n";
|
||||||
$allowskipping = false;
|
$allowskipping = false;
|
||||||
@@ -36,19 +42,22 @@ else
|
|||||||
//making sure ffmpeg is executable
|
//making sure ffmpeg is executable
|
||||||
system("chmod +x ".ROOT.DS.'bin'.DS.'ffmpeg');
|
system("chmod +x ".ROOT.DS.'bin'.DS.'ffmpeg');
|
||||||
|
|
||||||
echo "[i] Finding local mp4 files ..";
|
if(count($localfiles)==0)
|
||||||
while (false !== ($filename = readdir($dh))) {
|
{
|
||||||
$img = $dir.$filename.DS.$filename;
|
echo "[i] Finding local mp4 files\n";
|
||||||
if(!file_exists($img)) continue;
|
while (false !== ($filename = readdir($dh))) {
|
||||||
$type = pathinfo($img, PATHINFO_EXTENSION);
|
$img = $dir.$filename.DS.$filename;
|
||||||
$type = $pm->isTypeAllowed($type);
|
if(!file_exists($img)) continue;
|
||||||
if($type=='mp4')
|
$type = pathinfo($img, PATHINFO_EXTENSION);
|
||||||
$localfiles[] = $filename;
|
$type = $pm->isTypeAllowed($type);
|
||||||
|
if($type=='mp4')
|
||||||
|
$localfiles[] = $filename;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(count($localfiles)==0) exit('No MP4 files found'."\n");
|
if(count($localfiles)==0) exit('No MP4 files found'."\n");
|
||||||
|
|
||||||
echo " done. Got ".count($localfiles)." files\n";
|
echo "[i] Got ".count($localfiles)." files\n";
|
||||||
|
|
||||||
echo "[i] Starting to convert\n";
|
echo "[i] Starting to convert\n";
|
||||||
foreach($localfiles as $hash)
|
foreach($localfiles as $hash)
|
||||||
@@ -59,7 +68,7 @@ foreach($localfiles as $hash)
|
|||||||
echo "Skipping $hash\n";
|
echo "Skipping $hash\n";
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$cmd = "../bin/ffmpeg -y -i $img -loglevel panic -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 = 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";
|
||||||
echo " [i] Converting $hash";
|
echo " [i] Converting $hash";
|
||||||
system($cmd);
|
system($cmd);
|
||||||
echo "\tdone\n";
|
echo "\tdone\n";
|
||||||
|
|||||||
Reference in New Issue
Block a user