Просмотр исходного кода

#3024 Option to limit number of threads used by ffmpeg for video conversion

Alex Trofimov 6 лет назад
Родитель
Сommit
a0a3cd0f9d
1 измененных файлов с 13 добавлено и 1 удалено
  1. 13 1
      inc/classes/BxDolTranscoderVideo.php

+ 13 - 1
inc/classes/BxDolTranscoderVideo.php

@@ -209,7 +209,7 @@ class BxDolTranscoderVideo extends BxDolTranscoder implements iBxDolFactoryObjec
             @unlink($sFileOut);
             @unlink($sFileOut);
         }
         }
 
 
-        $sCommand = escapeshellcmd(BX_SYSTEM_FFMPEG) . ' -y -i ' . escapeshellarg($sFile) . ' ' . $sOptions . ' ' . escapeshellarg($sFileOut) . ' 2>&1';
+        $sCommand = escapeshellcmd(BX_SYSTEM_FFMPEG) . ' -y ' . $this->_getFfmpegThreadsParams() . ' -i ' . escapeshellarg($sFile) . ' ' . $this->_getFfmpegThreadsParams() . ' ' . $sOptions . ' ' . escapeshellarg($sFileOut) . ' 2>&1';
         $sOutput = `$sCommand`;
         $sOutput = `$sCommand`;
         $this->addToLog("\n---\n{$sCommand}\n{$sOutput}\n");
         $this->addToLog("\n---\n{$sCommand}\n{$sOutput}\n");
 
 
@@ -284,6 +284,18 @@ class BxDolTranscoderVideo extends BxDolTranscoder implements iBxDolFactoryObjec
 
 
         return '640x360'; // should never happen
         return '640x360'; // should never happen
     }
     }
+
+    protected function _getFfmpegThreadsParams ()
+    {
+        $s = '';
+
+        // optionally limit number of threads
+        if (defined('BX_SYSTEM_FFMPEG_THREAD') && ($iThreads = (int)constant('BX_SYSTEM_FFMPEG_THREAD'))) {
+            $s .= '-threads ' . $iThreads;
+        }
+
+        return $s;
+    }
 }
 }
 
 
 /** @} */
 /** @} */