Example #1
0
 /**
  * Asyncrhonous Convert all Video format to video/webm
  *   
  * Use ffmpeg for conversion
  * @return void
  * @author Cédric Levasseur
  */
 public static function FastEncodeVideo($file)
 {
     $basefile = new File($file);
     $basepath = File::a2r($file);
     $path_thumb_webm = File::Root() . '/' . Settings::$thumbs_dir . dirname($basepath) . "/" . $basefile->name . '.webm';
     $path_thumb_jpg = File::Root() . '/' . Settings::$thumbs_dir . dirname($basepath) . "/" . $basefile->name . '.jpg';
     if (!file_exists($path_thumb_webm) || filectime($file) > filectime($path_thumb_webm)) {
         /// Create Folder
         if (!file_exists(dirname($path_thumb_webm))) {
             @mkdir(dirname($path_thumb_webm), 0755, true);
         }
     }
     error_log($file, 0);
     error_log($path_thumb_webm, 0);
     if ($basefile->extension != "webm") {
         if (!file_exists($path_thumb_webm)) {
             ///Create Thumbnail jpg in  Thumbs folder
             $u = Settings::$ffmpeg_path . ' -itsoffset -4  -i ' . $file . ' -vcodec mjpeg -vframes 1 -an -f rawvideo -s 320x240 -y ' . $path_thumb_jpg;
             error_log($u, 0);
             pclose(popen('start /b ' . $u . '', 'r'));
             ///Convert video to webm format in Thumbs folder
             $u = Settings::$ffmpeg_path . ' -threads 4 -i ' . $file . ' ' . Settings::$ffmpeg_option . ' -y ' . $path_thumb_webm . ' 2>&1';
             error_log($u, 0);
             pclose(popen('start /b ' . $u . '', 'r'));
         }
     } else {
         //Create Thumbnail jpg in Thumbs folder
         $u = Settings::$ffmpeg_path . ' -itsoffset -4  -i ' . $file . ' -vcodec mjpeg -vframes 1 -an -f rawvideo -s 320x240 -y ' . $path_thumb_jpg;
         pclose(popen('start /b ' . $u . '', 'r'));
         ///Copy original webm video to Thumbs folder
         copy($file, $path_thumb_webm);
     }
 }