Skip to content

Commit

Permalink
Merge pull request #140 from D4nte/master
Browse files Browse the repository at this point in the history
Many commits: video, cleaning and google plus
  • Loading branch information
thibaud-rohmer committed Apr 13, 2012
2 parents 205982b + a2fd26a commit 77fa3df
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 14 deletions.
4 changes: 2 additions & 2 deletions inc/loc/default.ini
Expand Up @@ -24,9 +24,9 @@ generate = "Generate recursively thumbs and web images"
folder = "Folder"
all = "All"
gener = "Generate"
video_comment = "PhotoShow only displays videos in WebM. You can set the encoding to convert other formats to webm"
video_comment = "PhotoShow only displays videos in WebM. You can set the encoding to convert to other formats than webm"
encode_video = "Encode Video Activate"
ffmpeg_path = "Path ffmpeg"
ffmpeg_path = "FFmpeg path"
ffmpeg_option = "Encoding option"

[account]
Expand Down
7 changes: 4 additions & 3 deletions src/classes/Board.php
Expand Up @@ -261,12 +261,13 @@ private function foldergrid(){
* @author Thibaud Rohmer
*/
private function ratio($file){
// Calculate ratio
list($x,$y) = getimagesize($file);

// Non-image file : ratio = 2
if( ! File::Type($file) || File::Type($file) != "Image"){
if( ! File::Type($file) || File::Type($file) != "Image" || $y == 0 ){
return 2;
}
// Calculate ratio
list($x,$y) = getimagesize($file);

return floor($x/$y)+1;

Expand Down
21 changes: 14 additions & 7 deletions src/classes/Cleaning.php
Expand Up @@ -68,19 +68,17 @@ static public function PerformClean(){
}

//TODO Windows
// Clean Old thumbnails
exec("cd ".Settings::$thumbs_dir." && find . -type f -iregex '.*[^\(xml\)\(job\)]$' 2>&1", $output, $ret_var);

if ($ret_var != 0) {
error_log("ERROR/Cleaning::PerformClean: Execution failed: ".print_r($output));
}

$count = 0;
foreach ($output as $file) {
if (!file_exists(Settings::$photos_dir.'/'.$file) ){
error_log('DEBUG/Cleaning::PerformClean: erase '.Settings::$thumbs_dir.'/'.$file."\n");
if (unlink(Settings::$thumbs_dir.'/'.$file)){
$count++;
}
unlink(Settings::$thumbs_dir.'/'.$file);
}
}

Expand All @@ -101,15 +99,24 @@ static public function PerformClean(){

if (empty($files)){
error_log("ERROR/Cleaning::PerformClean: no file found for job ".$jobfilename.", deleting\n");
unlink(Settings::$thumbs_dir.'/'.$jobfilename);
continue;
}

//error_log('DEBUG/Cleaning::PerformClean: calling NoJob with '.$files[0]."\n");
if (Video::NoJob($files[0])){
$count++;
}
Video::NoJob($files[0]);
}

// Finally clean empty files
unset($output); unset($ret_var);
exec("cd ".Settings::$thumbs_dir." && find . -size 0b 2>&1", $output, $ret_var);
if ($ret_var != 0) {
error_log("ERROR/Cleaning::PerformClean: Execution failed: ".print_r($output));
return;
}
foreach ($output as $emptyfile) {
unlink(Settings::$thumbs_dir.'/'.$emptyfile);
}
}
}
?>
4 changes: 3 additions & 1 deletion src/classes/Settings.php
Expand Up @@ -134,7 +134,7 @@ class Settings extends Page
static public $ffmpeg_path = "/usr/bin/ffmpeg";

///FFMPEG Option
static public $ffmpeg_option = "-qmax 40 -acodec libvorbis -ab 128k";
static public $ffmpeg_option = "-threads 4 -qmax 40 -acodec libvorbis -ab 128k -ar 41000 -vcodec libvpx";


/**
Expand Down Expand Up @@ -388,11 +388,13 @@ public function toHTML(){
echo "<label><input type='checkbox' name='like'>".Settings::_("settings","fb")."</label>\n";
}

/*
if(Settings::$plusone){
echo "<label><input type='checkbox' name='plusone' checked>".Settings::_("settings","plusone")."</label>\n";
}else{
echo "<label><input type='checkbox' name='plusone'>".Settings::_("settings","plusone")."</label>\n";
}
*/

echo "</div></fieldset>\n";

Expand Down
2 changes: 1 addition & 1 deletion src/classes/Video.php
Expand Up @@ -198,7 +198,7 @@ public static function FastEncodeVideo($file) {
if ($file_file->extension !="webm") {
///Convert video to webm format in Thumbs folder
//TODO: Max job limit
$u = Settings::$ffmpeg_path.' -threads 4 -i "'.$file.'" '.Settings::$ffmpeg_option.' -y "'.$thumb_path_webm.'"';
$u = Settings::$ffmpeg_path.' -i "'.$file.'" '.Settings::$ffmpeg_option.' -y "'.$thumb_path_webm.'"';
$pid = self::ExecInBackground($u);
self::CreateJob($file, $pid);
}
Expand Down

0 comments on commit 77fa3df

Please sign in to comment.