コード例 #1
0
function _convert($sId)
{
    global $sModule;
    global $sFilesPath;
    $sTempFile = $sFilesPath . $sId;
    $sSourceFile = $sTempFile;
    $bUseX264 = vcUsex264();
    $sTmpl = vcPrepareCommand($GLOBALS['aConvertTmpls'][$bUseX264 ? "playX264" : "play"], array("bitrate" => _getVideoBitrate(), "audio_options" => $bUseX264 ? " -acodec aac -strict experimental -b:a 128k -ar 44100 " : " -acodec libmp3lame -b:a 128k -ar 44100 "));
    if (file_exists($sTempFile) && filesize($sTempFile) > 0) {
        $sTmpl = vcPrepareCommand($sTmpl, array("input" => $sTempFile, "size" => _getVideoSize($sTempFile)));
    } else {
        $sSourceFile .= VC_FLV_EXTENSION;
        if (file_exists($sSourceFile) && filesize($sSourceFile) > 0) {
            $sTmpl = vcPrepareCommand($sTmpl, array("input" => $sSourceFile, "size" => _getVideoSize($sSourceFile)));
        }
    }
    if (empty($sTmpl)) {
        return false;
    }
    $sDBModule = DB_PREFIX . ucfirst($sModule);
    getResult("UPDATE `" . $sDBModule . "Files` SET `Date`='" . time() . "', `Status`='" . VC_STATUS_PROCESSING . "' WHERE `ID`='" . $sId . "'");
    $bResult = _convertMain($sId, $sTmpl);
    if (!$bResult) {
        return false;
    }
    $oAlert = new BxDolAlerts('bx_video_comments', 'convert', $sId, getLoggedId(), array('result' => &$bResult, 'ffmpeg' => $GLOBALS['sFfmpegPath'], 'tmp_file' => $sTempFile, 'bitrate' => _getVideoBitrate(), 'size' => _getVideoSize($sTempFile)));
    $oAlert->alert();
    if ($bResult) {
        $sAutoApprove = getSettingValue($sModule, "autoApprove") == TRUE_VAL ? VC_STATUS_APPROVED : VC_STATUS_DISAPPROVED;
        getResult("UPDATE `" . $sDBModule . "Files` SET `Date`='" . time() . "', `Status`='" . $sAutoApprove . "' WHERE `ID`='" . $sId . "'");
    } else {
        getResult("UPDATE `" . $sDBModule . "Files` SET `Status`='" . VC_STATUS_FAILED . "' WHERE `ID`='" . $sId . "'");
    }
    _deleteTempFiles($sId);
    return $bResult;
}
コード例 #2
0
ファイル: functions.inc.php プロジェクト: dalinhuang/shopexts
function _convert($sId)
{
    global $sModule;
    global $sFilesPath;
    $sTempFile = $sFilesPath . $sId;
    $sSourceFile = $sTempFile;
    $bUseX264 = vcUsex264();
    $sTmpl = vcPrepareCommand($GLOBALS['aConvertTmpls'][$bUseX264 ? "playX264" : "play"], array("bitrate" => _getVideoBitrate(), "audio_options" => $bUseX264 ? "-acodec libfaac -ab 128kb -ac 2 -ar 44100" : "-acodec libmp3lame -ar 44100"));
    if (file_exists($sTempFile) && filesize($sTempFile) > 0) {
        $sTmpl = vcPrepareCommand($sTmpl, array("input" => $sTempFile, "size" => _getVideoSize($sTempFile)));
    } else {
        $sSourceFile .= VC_FLV_EXTENSION;
        if (file_exists($sSourceFile) && filesize($sSourceFile) > 0) {
            $sTmpl = vcPrepareCommand($sTmpl, array("input" => $sSourceFile, "size" => _getVideoSize($sSourceFile)));
        }
    }
    if (empty($sTmpl)) {
        return false;
    }
    $sDBModule = DB_PREFIX . ucfirst($sModule);
    getResult("UPDATE `" . $sDBModule . "Files` SET `Date`='" . time() . "', `Status`='" . VC_STATUS_PROCESSING . "' WHERE `ID`='" . $sId . "'");
    $bResult = _convertMain($sId, $sTmpl);
    if (!$bResult) {
        return false;
    }
    $sMobileFile = $sTempFile . VC_MOBILE_EXTENSION;
    $sMobileCommand = vcPrepareCommand($GLOBALS['aConvertTmpls']['mobile'], array("input" => $sSourceFile, "size" => "qcif", "output" => $sMobileFile));
    $bResult = convertFile($sMobileFile, $sMobileCommand);
    if ($bResult) {
        $sAutoApprove = getSettingValue($sModule, "autoApprove") == TRUE_VAL ? VC_STATUS_APPROVED : VC_STATUS_DISAPPROVED;
        getResult("UPDATE `" . $sDBModule . "Files` SET `Date`='" . time() . "', `Status`='" . $sAutoApprove . "' WHERE `ID`='" . $sId . "'");
    } else {
        getResult("UPDATE `" . $sDBModule . "Files` SET `Status`='" . VC_STATUS_FAILED . "' WHERE `ID`='" . $sId . "'");
    }
    _deleteTempFiles($sId);
    return $bResult;
}