Ejemplo n.º 1
0
function convertVideo($sId)
{
    global $sModule;
    global $sFilesPath;
    $sTempFile = $sFilesPath . $sId;
    $sSourceFile = $sTempFile;
    $bUseX264 = usex264();
    $sTmpl = prepareCommand($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 = prepareCommand($sTmpl, array("input" => $sTempFile, "size" => getVideoSize($sTempFile)));
    } else {
        $sSourceFile .= FLV_EXTENSION;
        if (file_exists($sSourceFile) && filesize($sSourceFile) > 0) {
            $sTmpl = prepareCommand($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`='" . STATUS_PROCESSING . "' WHERE `ID`='" . $sId . "'");
    $bResult = convertMainVideo($sId, $sTmpl);
    if (!$bResult) {
        return false;
    }
    $sMobileFile = $sTempFile . MOBILE_EXTENSION;
    $sMobileCommand = prepareCommand($GLOBALS['aConvertTmpls']['mobile'], array("input" => $sSourceFile, "size" => "qcif", "output" => $sMobileFile));
    $bResult = convertVideoFile($sMobileFile, $sMobileCommand);
    if ($bResult) {
        $sAutoApprove = getSettingValue($sModule, "autoApprove") == TRUE_VAL ? STATUS_APPROVED : STATUS_DISAPPROVED;
        getResult("UPDATE `" . $sDBModule . "Files` SET `Date`='" . time() . "', `Status`='" . $sAutoApprove . "' WHERE `ID`='" . $sId . "'");
    } else {
        getResult("UPDATE `" . $sDBModule . "Files` SET `Status`='" . STATUS_FAILED . "' WHERE `ID`='" . $sId . "'");
    }
    deleteTempFiles($sId);
    return $bResult;
}
Ejemplo n.º 2
-1
function convertVideo($sId)
{
    global $sModule;
    global $sFilesPath;
    $sTempFile = $sFilesPath . $sId;
    $sSourceFile = $sTempFile;
    $bUseX264 = usex264();
    $sTmpl = prepareCommand($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 = prepareCommand($sTmpl, array("input" => $sTempFile, "size" => getVideoSize($sTempFile)));
    } else {
        $sSourceFile .= FLV_EXTENSION;
        if (file_exists($sSourceFile) && filesize($sSourceFile) > 0) {
            $sTmpl = prepareCommand($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`='" . STATUS_PROCESSING . "' WHERE `ID`='" . $sId . "'");
    $bResult = convertMainVideo($sId, $sTmpl);
    if (!$bResult) {
        return false;
    }
    $oAlert = new BxDolAlerts('bx_videos', '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 ? STATUS_APPROVED : STATUS_DISAPPROVED;
        getResult("UPDATE `" . $sDBModule . "Files` SET `Date`='" . time() . "', `Status`='" . $sAutoApprove . "' WHERE `ID`='" . $sId . "'");
    } else {
        getResult("UPDATE `" . $sDBModule . "Files` SET `Status`='" . STATUS_FAILED . "' WHERE `ID`='" . $sId . "'");
    }
    deleteTempFiles($sId);
    return $bResult;
}