Esempio n. 1
0
function hg_get_cmd_file($pre = 'get_')
{
    $filename = 'cmd/' . $pre . time() . mt_rand(1, 99999);
    while (is_file($filename)) {
        $filename = hg_get_cmd_file();
    }
    return $filename;
}
Esempio n. 2
0
    $curl = new curl($gVodApi['host'], $gVodApi['dir'] . 'admin/', $gVodApi['token']);
    $curl->initPostData();
    $curl->setSubmitType('post');
    $curl->addRequestData('a', $a);
    foreach ($vod as $k => $v) {
        $curl->addRequestData($k, $v);
    }
    $ret = $curl->request('vod_update.php');
    if (is_array($ret)) {
        $vodid = intval($ret[0]['id']);
    }
    $video_list_file = 'video_' . date('Ymd') . '.list';
    file_put_contents(UPLOAD_DIR . $video_list_file, $last_id . ';', FILE_APPEND);
} else {
    $vodid = intval($_INPUT['id']);
}
$stream = $stream . $starttime . '000,' . $endtime . '000';
$savefile = UPLOAD_DIR . $filepath;
if ($_INPUT['status']) {
    $extra = '&status=' . $_INPUT['status'];
}
if ($_INPUT['force_codec']) {
    $extra .= '&force_codec=' . $_INPUT['force_codec'];
}
$curl_cmd = 'curl "' . $stream . '" > "' . $savefile . '"' . "\n";
file_put_contents('../tmp/cmd_' . $channel_id . $starttime . '000,' . $endtime . '000' . '.txt', $curl_cmd);
$curl_cmd .= 'curl "http://' . $gTransApi['host'] . '/' . $gTransApi['dir'] . 'recode.php?auth=' . $gTransApi['token'] . '&id=' . $vodid . '&vodid=' . $last_id . $extra . '"';
$filename = hg_get_cmd_file('record_');
file_put_contents($filename, $curl_cmd);
$data = array('id' => $vodid ? $vodid : $last_id, 'vodid' => $last_id, 'type' => $filetype, 'size' => $filesize, 'path' => UPLOAD_DIR . $filepath . $endtime . '-' . $starttime, 'admin_id' => $vod['admin_id'], 'admin_name' => $vod['admin_name']);
output($data);
Esempio n. 3
0
$filepath = urldecode($_INPUT['filepath']);
$target = MP4_TARGET_DIR . $filepath;
$vod_media_target = TARGET_DIR . $filepath;
hg_mkdir($target);
hg_mkdir($vod_media_target);
//file_put_contents('debug/d.txt', $source . "\n" . $target);
$path = explode('/', $source);
unset($path[count($path) - 1]);
$path = implode('/', $path);
if (is_file($target . 'out')) {
    $cmd = 'mp4split -o ' . $vod_media_target . $filename . '.ismv ' . $target . $filename . '.mp4';
    $cmd .= "\n" . 'mp4split -o ' . $vod_media_target . $filename . '.ism ' . $vod_media_target . $filename . '.ismv';
    $filename = hg_get_cmd_file();
    file_put_contents($filename, $cmd);
    output(array('msg' => 'success'));
}
@unlink($target . $filename . '.mp4');
@unlink($target . 'preview.jpg');
@unlink($target . 'media_info');
$cmd = 'cd ' . $target . " \nwget " . $source;
$cmd .= " \nwget " . $path . "/preview.jpg";
$cmd .= " \nwget " . $path . "/media_info";
$cmd .= "\n" . 'mp4split -o ' . $vod_media_target . $filename . '.ismv ' . $target . $filename . '.mp4';
$cmd .= "\n" . 'mp4split -o ' . $vod_media_target . $filename . '.ism ' . $vod_media_target . $filename . '.ismv';
$cmd .= "\n" . 'chmod -Rf 777 ' . $target;
if (WOWZA_DIR) {
    $cmd .= "\n" . 'ln -s ' . $target . $filename . '.mp4' . ' ' . WOWZA_DIR . $filename . '.mp4';
}
$filename = hg_get_cmd_file();
file_put_contents($filename, $cmd);
output(array('msg' => 'success'));
Esempio n. 4
0
$stream_id = $_INPUT['stream_id'];
if (!$stream) {
    error_output('001', '未指定流地址');
}
$stream_id = $_INPUT['stream_id'];
if (!$stream_id) {
    error_output('002', '未指定流ID');
}
/*
$cmd = FFMPEG_CMD . ' -i ' . $stream;
exec($cmd, $out, $s);
print_r($out);*/
$out = realpath(ROOT_DIR . 'tmp') . '/' . $stream_id . '.out';
$cmd = FFMPEG_CMD . ' -i ' . $stream . ' &> ' . $out . " \n";
$cmd .= 'chmod 777 ' . $out . "\n";
$filename = hg_get_cmd_file('get_bitrate_');
file_put_contents($filename, $cmd);
$time = TIMENOW;
$timesleep = 0;
while (!is_file($out) && $timesleep < 10) {
    sleep(1);
    $timesleep = time() - $time;
}
if (is_file($out)) {
    $rate = hg_get_rate($out);
    $time = time();
    while (!$rate && $timesleep < 10) {
        sleep(1);
        $rate = hg_get_rate($out);
        $timesleep = time() - $time;
    }