mirror of
https://github.com/HaschekSolutions/pictshare.git
synced 2025-11-20 06:58:00 +00:00
fixed bug in re encode script
This commit is contained in:
@@ -59,21 +59,41 @@ if(count($localfiles)==0) exit('No MP4 files found'."\n");
|
||||
|
||||
echo "[i] Got ".count($localfiles)." files\n";
|
||||
|
||||
|
||||
//TESTING
|
||||
echo "[i] Checking hashes for wrongly encoded ones\n";
|
||||
foreach($localfiles as $akey => $hash)
|
||||
{
|
||||
$mp4 = $dir.$hash.DS.$hash;
|
||||
$cmd = ROOT.DS.'bin'.DS."ffmpeg -i $mp4 -hide_banner 2> ".ROOT.DS.'tmp'.DS.$hash.'.txt';
|
||||
system($cmd);
|
||||
$results = file(ROOT.DS.'tmp'.DS.$hash.'.txt');
|
||||
foreach($results as $l)
|
||||
{
|
||||
$elements = explode(':',trim($l));
|
||||
$key=trim(array_shift($elements));
|
||||
$value = trim(implode(':',$elements));
|
||||
if($key=='encoder')
|
||||
{
|
||||
if(startsWith(strtolower($value),'lav'))
|
||||
{
|
||||
echo " [i] Removing $hash because it's already correctly encoded\n";
|
||||
unset($localfiles[$akey]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo "[i] Starting to convert\n";
|
||||
foreach($localfiles as $hash)
|
||||
{
|
||||
$img = $dir.$hash.DS.$hash;
|
||||
$mp4 = $dir.$hash.DS.$hash;
|
||||
$tmp = ROOT.DS.'tmp'.DS.$hash;
|
||||
if(file_exists($tmp) && $allowskipping==true)
|
||||
echo "Skipping $hash\n";
|
||||
else
|
||||
{
|
||||
$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";
|
||||
$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";
|
||||
echo " [i] Converting '$hash'";
|
||||
system($cmd);
|
||||
if(defined('ALT_FOLDER') && ALT_FOLDER && isdir(ALT_FOLDER))
|
||||
copy($img,ALT_FOLDER.DS.$hash);
|
||||
if(defined('ALT_FOLDER') && ALT_FOLDER && is_dir(ALT_FOLDER))
|
||||
copy($mp4,ALT_FOLDER.DS.$hash);
|
||||
echo "\tdone\n";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user