コード例 #1
0
ファイル: start.php プロジェクト: juho-jaakkola/elgg-videos
/**
 * Trigger the video conversion
 */
function video_conversion_cron($hook, $entity_type, $returnvalue, $params)
{
    $ia = elgg_set_ignore_access(true);
    $videos = elgg_get_entities_from_metadata(array('type' => 'object', 'subtype' => 'video', 'limit' => 2, 'metadata_name_value_pairs' => array('name' => 'conversion_done', 'value' => 0)));
    elgg_load_library('elgg:video');
    foreach ($videos as $video) {
        $sources = $video->getSources();
        $success = true;
        foreach ($sources as $source) {
            // Converted sources may exist if previous conversion has been interrupted
            if ($source->conversion_done == true) {
                continue;
            }
            try {
                $filename = $source->getFilenameOnFilestore();
                // Create a new video file to data directory
                $converter = new VideoConverter();
                $converter->setInputFile($video->getFilenameOnFilestore());
                $converter->setOutputFile($filename);
                $converter->setResolution($source->resolution);
                $converter->setBitrate($source->bitrate);
                $result = $converter->convert();
                // Save video details
                $info = new VideoInfo($source);
                $source->resolution = $info->getResolution();
                $source->bitrate = $info->getBitrate();
                $source->conversion_done = true;
                $source->save();
                echo "<p>Successfully created video file {$source->getFilename()}</p>";
            } catch (Exception $e) {
                // Print simple error to screen
                echo "<p>Failed to create video file {$source->getFilename()}</p>";
                $success = false;
                // Print detailed error to error log
                $message = elgg_echo('VideoException:ConversionFailed', array($filename, $e->getMessage(), $converter->getCommand()));
                error_log($message);
                elgg_add_admin_notice('conversion_error', $message);
            }
        }
        if ($success) {
            $video->conversion_done = true;
            add_to_river('river/object/video/create', 'create', $video->getOwnerGUID(), $video->getGUID());
        }
    }
    elgg_set_ignore_access($ia);
    return $returnvalue;
}
コード例 #2
0
ファイル: getFileTypes.php プロジェクト: sahartak/youtube
<?php

session_start();
header('Access-Control-Allow-Origin: *');
// Autoload class files
spl_autoload_register(function ($className) {
    if (!class_exists($className)) {
        include '../' . $className . '.class.php';
    }
});
// Instantiate converter class
$converter = new VideoConverter();
$ftypes = $converter->GetConvertedFileTypes();
$output = '';
foreach ($ftypes as $key => $ftype) {
    $output .= '<input type="radio" value="' . $key . '" name="ftype" ';
    $output .= isset($ftype['checked']) ? 'checked="checked" ' : '';
    $output .= '/>.' . $ftype['fileExt'];
    $output .= isset($ftype['quality']) ? ' (' . $ftype['quality'] . 'kb)' : '';
    $output .= $ftype != end($ftypes) ? ' &nbsp;' : '';
}
$output .= '<input type="hidden" name="bookmarklet" value="1" />';
echo $output . "^^^" . (int) Config::_SSL_ENABLED;
コード例 #3
0
ファイル: index.php プロジェクト: sahartak/youtube
    $_SESSION['langs'] = $localize->GetLocalizationInfo();
    $_SESSION['translations'] = $localize->GetTranslations();
    $_SESSION['missingTranslations'] = $localize->GetMissingTranslations();
}
foreach ($_SESSION['translations'] as $constant => $value) {
    $value = isset($_SESSION['missingTranslations'][$constant]) && $_SESSION['langs'][$_SESSION['ccode']]['direction'] == 'rtl' ? '<span dir="' . Localize::_FALLBACK_DIRECTION . '">' . $value . '</span>' : $value;
    define($constant, $value);
}
// If localization just changed, urldecode everything in $_GET that was encoded by http_build_query()
if (isset($_GET['ccode'])) {
    foreach ($_GET as $k => $v) {
        $_GET[$k] = urldecode($v);
    }
}
// Instantiate converter class and populate vars/arrays
$converter = new VideoConverter();
$videoHosts = $converter->GetVideoHosts();
$uniqueFtypes = $ftypes = $converter->GetConvertedFileTypes();
$editableFtypes = array();
$fileExts = array();
$mimeTypes = array();
$checkedExt = current(array_keys($ftypes));
array_walk($ftypes, function ($ftype, $key) use(&$editableFtypes, &$fileExts, &$checkedExt, &$mimeTypes) {
    if (isset($ftype['jPlayerName']) && !isset($editableFtypes[$ftype['fileExt']])) {
        $editableFtypes[$ftype['fileExt']] = isset($ftype['modernizrType']) ? $ftype['modernizrType'] : '';
    }
    $fileExts[$key] = $ftype['fileExt'];
    if (isset($ftype['checked'])) {
        $checkedExt = $key;
    }
    $mimeTypes[$key] = $ftype['mimeType'];
コード例 #4
0
ファイル: edit.php プロジェクト: sahartak/youtube
    $_SESSION['langs'] = $localize->GetLocalizationInfo();
    $_SESSION['translations'] = $localize->GetTranslations();
    $_SESSION['missingTranslations'] = $localize->GetMissingTranslations();
}
foreach ($_SESSION['translations'] as $constant => $value) {
    $value = isset($_SESSION['missingTranslations'][$constant]) && $_SESSION['langs'][$_SESSION['ccode']]['direction'] == 'rtl' ? '<span dir="' . Localize::_FALLBACK_DIRECTION . '">' . $value . '</span>' : $value;
    define($constant, $value);
}
// If localization just changed, urldecode everything in $_GET that was encoded by http_build_query()
if (isset($_GET['ccode'])) {
    foreach ($_GET as $k => $v) {
        $_GET[$k] = urldecode($v);
    }
}
// Instantiate converter class
$converter = new VideoConverter();
$vidHosts = array_values($converter->GetVideoHosts());
$ftypes = $converter->GetConvertedFileTypes();
// On download of edited file
if (isset($_GET['dload'])) {
    $converter->DownloadConvertedFile($_GET['dload'], Config::_EDITED_CONVERTED_FILEDIR);
}
// Determine jPlayer media type
$mediaType = $fileExt = 'mp3';
$mediaTypeArr = array($mediaType);
$avFormat = 'audio';
$solutionOrder = 'html, flash';
$enableMetadataEditor = false;
if (isset($_GET['vid_name'])) {
    $fileExt = end(explode(".", $_GET['vid_name']));
    foreach ($ftypes as $ftype) {
コード例 #5
0
ファイル: ffmpeg_edit.php プロジェクト: sahartak/youtube
});
// Configure localization
$countryCode = !isset($_GET['ccode']) ? !isset($_SESSION['ccode']) ? Config::_DEFAULT_COUNTRY : $_SESSION['ccode'] : trim($_GET['ccode']);
if (!isset($_SESSION['langs']) || !isset($_SESSION['translations']) || !isset($_SESSION['missingTranslations']) || !isset($_SESSION['ccode']) || $_SESSION['ccode'] != $countryCode) {
    $localize = new Localize($countryCode);
    $_SESSION['ccode'] = $countryCode;
    $_SESSION['langs'] = $localize->GetLocalizationInfo();
    $_SESSION['translations'] = $localize->GetTranslations();
    $_SESSION['missingTranslations'] = $localize->GetMissingTranslations();
}
foreach ($_SESSION['translations'] as $constant => $value) {
    $value = isset($_SESSION['missingTranslations'][$constant]) && $_SESSION['langs'][$_SESSION['ccode']]['direction'] == 'rtl' ? '<span dir="' . Localize::_FALLBACK_DIRECTION . '">' . $value . '</span>' : $value;
    define($constant, $value);
}
// Instantiate converter class
$converter = new VideoConverter();
$ftypes = $converter->GetConvertedFileTypes();
$uniqueFtypes = array();
array_walk($ftypes, function ($ftype, $key) use(&$uniqueFtypes) {
    if (!isset($uniqueFtypes[$ftype['fileExt']])) {
        $uniqueFtypes[$ftype['fileExt']] = $key;
    }
});
// Prepare data for FFmpeg
$start_time = (double) $_GET['min'];
$end_time = (double) $_GET['max'];
$song = $_GET['song'];
$token = $_GET['token'];
if (isset($_GET['atitle']) && isset($_GET['artist']) && isset($_GET['genre']) && isset($_GET['genreCode']) && isset($_GET['year']) && isset($_GET['album']) && isset($_GET['track'])) {
    $atitle = trim(stripslashes(urldecode($_GET['atitle'])));
    $artist = trim(stripslashes(urldecode($_GET['artist'])));
コード例 #6
0
    $_SESSION['langs'] = $localize->GetLocalizationInfo();
    $_SESSION['translations'] = $localize->GetTranslations();
    $_SESSION['missingTranslations'] = $localize->GetMissingTranslations();
}
foreach ($_SESSION['translations'] as $constant => $value) {
    $value = isset($_SESSION['missingTranslations'][$constant]) && $_SESSION['langs'][$_SESSION['ccode']]['direction'] == 'rtl' ? '<span dir="' . Localize::_FALLBACK_DIRECTION . '">' . $value . '</span>' : $value;
    define($constant, $value);
}
// If localization just changed, urldecode everything in $_GET that was encoded by http_build_query()
if (isset($_GET['ccode'])) {
    foreach ($_GET as $k => $v) {
        $_GET[$k] = urldecode($v);
    }
}
// Instantiate converter class and populate vars/arrays
$converter = new VideoConverter();
$vidHosts = array_values($converter->GetVideoHosts());
?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
	<title><?php 
echo Config::_SITENAME;
?>
 :: <?php 
echo $_SESSION['translations'][$pageTitle];
?>
</title>
コード例 #7
0
ファイル: page_meta_data.php プロジェクト: sahartak/youtube
<?php

$appRootDirectory = "VideoConverter/";
// Set the root directory and path of the conversion software, relative to the web root. Directory name/path must be followed by a trailing '/'. Do NOT prepend directory name/path with a '/'! An empty value indicates the web root directory. This value MUST be set if you are running the software inside an iframe!!
/* Edit below here at your own risk! */
$isUrlConversion = isset($_GET['vidID']) && !empty($_GET['vidID']) && isset($_GET['vidHost']) && !empty($_GET['vidHost']);
$metaDataInfo = isset($vidInfo) ? $vidInfo : array();
if (!isset($converter)) {
    // Autoload class files
    spl_autoload_register(function ($className) use($appRootDirectory) {
        if (!class_exists($className)) {
            include is_file($appRootDirectory . $className . '.class.php') ? $appRootDirectory . $className . '.class.php' : $appRootDirectory . 'extractors' . DIRECTORY_SEPARATOR . $className . '.php';
        }
    });
    if ($isUrlConversion) {
        session_start();
        $converter = new VideoConverter();
        $videoHosts = $converter->GetVideoHosts();
        foreach ($videoHosts as $host) {
            if (trim($_GET['vidHost']) == strtolower($host['name']) || trim($_GET['vidHost']) == $host['abbreviation']) {
                $extractorObj = new $host['name']($converter);
                $metaDataInfo = $extractorObj->RetrieveVidInfo($host['url_root'][0] . trim($_GET['vidID']));
                break;
            }
        }
    }
}
echo '<meta name="description" content="' . (!empty($metaDataInfo) ? htmlspecialchars($metaDataInfo['title'], ENT_QUOTES) . " - " : "") . htmlspecialchars(Config::$_defaultMetaData['description'], ENT_QUOTES) . '" /><meta name="keywords" content="' . (!empty($metaDataInfo) ? implode(",", preg_split('/ /', preg_replace('/[^\\p{L}\\p{N}]/u', " ", $metaDataInfo['title']), -1, PREG_SPLIT_NO_EMPTY)) . "," : "") . implode(",", preg_split('/ /', preg_replace('/[^\\p{L}\\p{N}]/u', " ", Config::$_defaultMetaData['title']), -1, PREG_SPLIT_NO_EMPTY)) . '" />';
echo !empty($metaDataInfo) ? '<meta property="og:title" content="' . Config::$_defaultMetaData['title'] . '" /><meta property="og:description" content="I just converted ' . htmlspecialchars($metaDataInfo['title'], ENT_QUOTES) . ' at ' . Config::_SITENAME . '!" /><meta property="og:image" content="' . $metaDataInfo['thumb_preview'] . '" /><meta name="twitter:card" content="summary_large_image" /><meta name="twitter:site" content="' . Config::$_defaultMetaData['twitter_id'] . '" /><meta name="twitter:title" content="' . Config::$_defaultMetaData['title'] . '" /><meta name="twitter:description" content="I just converted ' . htmlspecialchars($metaDataInfo['title'], ENT_QUOTES) . ' at ' . Config::_SITENAME . '!" /><meta name="twitter:image" content="' . $metaDataInfo['thumb_preview'] . '" />' : '<meta property="og:image" content="http://' . $_SERVER['HTTP_HOST'] . Config::_APPROOT . Config::$_defaultMetaData['image'] . '" />';
echo '<title>' . (!empty($metaDataInfo) ? $metaDataInfo['title'] . " - " : "") . Config::$_defaultMetaData['title'] . '</title>';
コード例 #8
0
ファイル: convert.php プロジェクト: juho-jaakkola/elgg-videos
} else {
    $basename = $video->getFilenameWithoutExtension();
    $filename = "video/{$video->getGUID()}/{$basename}_{$resolution}.{$format}";
    // Create a new entity that represents the physical file
    $source = new VideoSource();
    $source->format = $format;
    $source->setFilename($filename);
    $source->setMimeType("video/{$format}");
    $source->resolution = $resolution;
    $source->bitrate = $bitrate;
    $source->owner_guid = $video->getOwnerGUID();
    $source->container_guid = $video->getGUID();
    $source->access_id = $video->access_id;
    $source->save();
}
try {
    $converter = new VideoConverter();
    $converter->setInputfile($video->getFilenameOnFilestore());
    $converter->setOutputfile($source->getFilenameOnFilestore());
    $converter->setResolution($resolution);
    $converter->setBitrate($bitrate);
    $converter->convert();
    $source->conversion_done = true;
    system_message(elgg_echo('video:convert:success', array($format)));
} catch (exception $e) {
    // Delete the faulty format
    $source->delete();
    $message = elgg_echo('VideoException:ConversionFailed', array($outputfile, $e->getMessage(), $converter->getCommand()));
    register_error($message);
}
forward("admin/video/view?guid={$guid}");