Example #1
0
function test_deleteAppIoscert()
{
    global $apiKey;
    global $secretKey;
    $channel = new Channel($apiKey, $secretKey);
    //如果ios应用当前部署状态为开发状态,指定DEPLOY_STATUS为1,默认是生产状态,值为2.
    //旧版本曾采用不同的域名区分部署状态,仍然支持。
    //$optional[Channel::DEPLOY_STATUS] = 1;
    $ret = $channel->deleteAppIoscert();
    if (false === $ret) {
        error_output('WRONG, ' . __FUNCTION__ . ' ERROR!!!!');
        error_output('ERROR NUMBER: ' . $channel->errno());
        error_output('ERROR MESSAGE: ' . $channel->errmsg());
        error_output('REQUEST ID: ' . $channel->getRequestId());
    } else {
        right_output('SUCC, ' . __FUNCTION__ . ' OK!!!!!');
        right_output('result: ' . print_r($ret, true));
    }
}
Example #2
0
<?php

define('ROOT_DIR', '../');
require ROOT_DIR . 'global.php';
set_time_limit(0);
/**
* 视频上传接口
*
* 输入: videofile  $_FILES文件流
* 返回: json
array(
	'id' => $last_id, //视频id
	'type' => $filetype, //视频类型
	'size' =>  //视频总大小
);
* 错误返回: 001 - 未指定文件传输,002 - 非法的文件类型, 003 - 视频移动失败
*/
$id = $_INPUT['id'];
if (!$id) {
    error_output('001', '未指定视频ID');
}
$video_dir = hg_num2dir($id);
echo $targerdir = TARGET_DIR . $video_dir . $id . '.ssm/' . $id . '.mp4';
Example #3
0
    error_output('009', '通信令牌错误');
}
$id = $_INPUT['vodid'];
if (!$id) {
    error_output('001', '未指定视频ID');
}
$video_dir = hg_num2dir($id);
$targerdir = TARGET_DIR . $video_dir . $id . '.ssm/';
hg_mkdir($targerdir);
$start = intval($_INPUT['start']);
$duration = intval($_INPUT['duration']);
$mp4 = $targerdir . $id . '.mp4';
if (!is_file($mp4)) {
    $cmd = '/usr/local/bin/mp4split -o ' . $mp4 . ' ' . $targerdir . $id . '.ismv';
    exec($cmd);
}
if (!is_file($mp4)) {
    error_output('002', '原视频文件丢失');
}
$start = hg_mc_sec2format($start);
$duration = hg_mc_sec2format($duration);
$new_flv = TARGET_DIR . $video_dir . $id . '.flv';
//-ss ' . $start . ' -t ' . $duration . '
$cmd = FFMPEG_CMD . ' -y -i ' . $mp4 . ' -acodec copy  -vcodec copy ' . $new_flv;
//$cmd = FFMPEG_CMD . ' -y -ss ' . $start . ' -t ' . $duration . ' -i ' . $mp4 . ' -sameq ' . $new_mp4;
exec($cmd, $out, $s);
if (!is_file($new_flv)) {
    error_output('003', 'flv视频文件未能生成');
}
$data = array('vodid' => $id, 'filepath' => $video_dir, 'filename' => $id . '.flv');
output($data);
Example #4
0
/**
* 下载视频
*
* 输入: videofile  $_FILES文件流
* 返回: json
array(
	'id' => $last_id, //视频id
	'type' => $filetype, //视频类型
	'size' =>  //视频总大小
);
* cmd = 'ffmpeg -ss %s -s %dx%d "%s" -i "%s" -r 1 -vframes 1' % (snaptime, video_info['width'], video_info['height'], snapname, videoname)
**/
$source = urldecode($_INPUT['file']);
$filename = urldecode($_INPUT['filename']);
if (!$source || !$filename) {
    error_output('001', '源文件不存在');
}
$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);
Example #5
0
 function test_deleteAppIoscert()
 {
     $apiKey = $this->apiKey;
     $secretKey = $this->secretKey;
     $channel = new Channel($apiKey, $secretKey);
     $ret = $channel->deleteAppIoscert();
     if (false === $ret) {
         error_output('WRONG, ' . __FUNCTION__ . ' ERROR!!!!');
         error_output('ERROR NUMBER: ' . $channel->errno());
         error_output('ERROR MESSAGE: ' . $channel->errmsg());
         error_output('REQUEST ID: ' . $channel->getRequestId());
     } else {
         right_output('SUCC, ' . __FUNCTION__ . ' OK!!!!!');
         right_output('result: ' . print_r($ret, true));
     }
 }
Example #6
0
/**
* 视频上传接口
*
* 输入: videofile  $_FILES文件流
* 返回: json
array(
	'id' => $last_id, //视频id
	'type' => $filetype, //视频类型
	'size' =>  //视频总大小
);
* 错误返回: 001 - 未指定文件传输,002 - 非法的文件类型, 003 - 视频移动失败
*/
if (!in_array($_INPUT['auth'], $gToken)) {
    error_output('009', '通信令牌错误');
}
$id = $_INPUT['vodid'];
if (!$id) {
    error_output('001', '未指定视频ID');
}
$video_dir = hg_num2dir($id);
$targerdir = TARGET_DIR . $video_dir . $id . '.ssm/';
$mp4 = $targerdir . $id . '.mp4';
if (!is_file($mp4)) {
    $cmd = '/usr/local/bin/mp4split -o ' . $mp4 . ' ' . $targerdir . $id . '.ismv';
    exec($cmd);
}
if (!is_file($mp4)) {
    error_output('002', '原视频文件丢失');
}
$data = array('vodid' => $id, 'url' => THUMB_URL . $video_dir . $id . '.ssm/' . $id . '.mp4', 'filename' => $id . '.mp4');
output($data);
Example #7
0
    error_output('004', '时间设置过长');
}
$endtime = $endtime + 5;
if ($endtime > time()) {
    error_output('005', date('Y-m-d H:i:s', $endtime) . '节目尚未结束,请' . date('Y-m-d H:i:s', time()) . '开始');
}
$filetype = '.flv';
if (!$_INPUT['vodid']) {
    $last_id = hg_get_video_id();
    $a = 'create';
} else {
    $last_id = $_INPUT['vodid'];
}
$video_dir = hg_num2dir($last_id);
if (!hg_mkdir(UPLOAD_DIR . $video_dir) || !is_writeable(UPLOAD_DIR . $video_dir)) {
    error_output('004', UPLOAD_DIR . '目录不可写入文件');
}
$targerdir = TARGET_DIR . $video_dir . $last_id . '.ssm/';
hg_mkdir($targerdir);
$filepath = $video_dir . $last_id . $filetype;
if (!$_INPUT['id'] && $last_id && $gVodApi['host'] && $a) {
    $vod = array('vodid' => $last_id, 'totalsize' => $filesize, 'type' => $filetype, 'source' => $channel_id, 'starttime' => $starttime, 'delay_time' => $_INPUT['delay_time'], 'vod_sort_id' => $vod_sort_id, 'title' => $program, 'vod_leixing' => 3, 'admin_id' => $_INPUT['admin_id'], 'admin_name' => $_INPUT['admin_name'] ? $_INPUT['admin_name'] : '自动录制');
    include_once ROOT_DIR . 'lib/curl.class.php';
    $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');
Example #8
0
 private function onSubmit($l, $a, $d, $activate = 6)
 {
     error_output();
     if (isset($_POST['submit'])) {
         $restrict = array('index.html', 'index', '.htaccess', '..', 'http://', 'www', 'https://', '../', 'ftp', 'http', 'xml', 'css', 'php', 'php5', 'js', 'html');
         $z = strtolower(str_ireplace(' ', '_', $_POST['submit']));
         if ($z != 'upload') {
             foreach (@$_POST['img'] as $x) {
                 foreach ($restrict as $y) {
                     if (strchr($x, $y)) {
                         alert("This types of files are not allowed to download or delete.");
                         exit;
                     }
                 }
             }
         }
         switch ($z) {
             case 'delete':
                 isEmpty();
                 if ($activate == 6) {
                     foreach (@$_POST['img'] as $b) {
                         $x = basename($b, ".jpg");
                         try {
                             unlink("__types/__files/__img/" . $x . ".jpg");
                             unlink("__types/__files/__src/" . $x . ".php");
                             unlink("__types/__files/__json/" . $x . ".json");
                             unlink("__types/__files/__demo/" . $x . ".jpg");
                             alert($x . ' ' . $this->lang->admin->alert->fDeleted . ' ');
                         } catch (Exception $e) {
                             alert($this->lang->index->unknwnErr);
                         }
                     }
                 } else {
                     $c = count($this->clearInputData($_POST['img']));
                     $x = 0;
                     foreach (@$_POST['img'] as $b) {
                         unlink($d . '/' . $l . '/' . $b);
                         $x += 1;
                     }
                     alert($x . ' ' . $this->lang->admin->alert->fDeleted . ' ');
                 }
                 break;
             case 'delete_all':
                 if ($activate == 6) {
                     alert($x . ' ' . $this->lang->admin->alert->err_dlt_type . ' ');
                 } else {
                     $c = count($a);
                     $x = 0;
                     foreach ($a as $b) {
                         unlink($d . '/' . $l . '/' . $b);
                         $x += 1;
                     }
                 }
                 alert($x . ' ' . $this->lang->admin->alert->fDeleted . '');
                 break;
             case 'upload':
                 $c2i = $this->clearInputData(@$_POST['c2i']);
                 if ($l == "__images" && !empty($c2i)) {
                     self::doUpload($l, $d, $c2i);
                 } else {
                     if ($activate == 6) {
                         self::doUpload($l, $d, $activate);
                     } else {
                         self::doUpload($l, $d, $activate);
                     }
                 }
                 break;
             case 'make_default':
                 isEmpty();
                 rename($d . '/' . $l . '/bg.jpg', $d . '/' . $l . '/' . time() . '.jpg');
                 rename($d . '/' . $l . '/' . $_POST['img'][0], $d . '/' . $l . '/bg.jpg');
                 alert($this->lang->admin->alert->dataUpdated);
                 break;
             case 'default':
                 //isEmpty();
                 rename($d . '/' . $l . '/bg.jpg', $d . '/' . $l . '/' . time() . '.jpg');
                 //rename($d.'/'.$l.'/backup.jpg',$d.'/'.$l.'/bg.jpg');
                 copy($d . '/' . $l . '/backup/bg.jpg', $d . '/' . $l . '/bg.jpg');
                 alert($this->lang->admin->alert->dataUpdated);
                 break;
             case 'download':
             case 'download_all':
                 error_output();
                 if ($activate == 6) {
                     foreach (@$_POST['img'] as $b) {
                         try {
                             echo $b;
                             $x = basename($b, ".jpg");
                             $zip = new ZipArchive();
                             $filename = "__tmp/__tmp/" . $x . ".zip";
                             if ($zip->open($filename, ZIPARCHIVE::CREATE) !== TRUE) {
                                 exit($this->lang->admin->alert->cOpen . " <{$filename}>\n");
                             }
                             $zip->addFromString("readme.txt", ">-> This app code is downloaded from http://www.beingprogrammer.com <-<");
                             $zip->addFile("__types/__files/__img/" . $x . ".jpg");
                             $zip->addFile("__types/__files/__demo/" . $x . ".jpg");
                             $zip->addFile("__types/__files/__src/" . $x . ".php");
                             $zip->addFile("__types/__files/__json/" . $x . ".json");
                         } catch (Exception $e) {
                             alert($this->lang->admin->alert->err_download_app);
                         }
                     }
                 } else {
                     $zip = new ZipArchive();
                     $filename = "__tmp/__tmp/" . sha1(time()) . ".zip";
                     if ($zip->open($filename, ZIPARCHIVE::CREATE) !== TRUE) {
                         exit($this->lang->admin->alert->cOpen . " <{$filename}>\n");
                     }
                     $zip->addFromString("readme.txt", ">-> This app is downloaded from http://www.beingprogrammer.com <-<");
                     if ($z == 'download_all') {
                         $c = count($a);
                         foreach ($a as $b) {
                             $zip->addFile($d . '/' . $l . '/' . $b);
                         }
                     } else {
                         if ($z == 'download') {
                             foreach (@$_POST['img'] as $b) {
                                 $zip->addFile($d . '/' . $l . '/' . $b);
                             }
                         }
                     }
                 }
                 $zip->close();
                 echo '<script>window.top.location = "' . $filename . '"</script>';
                 break;
             case 'activate':
                 isEmpty();
                 foreach (@$_POST['img'] as $b) {
                     $filename = basename($b, ".jpg");
                     $file = '__types/__files/__src/' . $filename . '.php';
                     $img = '__types/__files/__img/' . $filename . '.jpg';
                     $json = '__types/__files/__json/' . $filename . '.json';
                     if (file_exists($file) && file_exists($img) && file_exists($json)) {
                         copy($img, "__photos/__bg/bg.jpg");
                         copy($img, "__photos/__bg/backup/bg.jpg");
                         copy($file, "__src/__plugs/index.php");
                         copy($json, "__src/__data/info.json");
                         alert("App " . $filename . " " . $this->lang->admin->alert->success_in_activate);
                     } else {
                         //output error
                         alert($this->lang->admin->alert->err_in_activate);
                     }
                 }
                 $s = scandir("__photos/__tmp/");
                 $c = count($s);
                 $x = 0;
                 foreach ($s as $b) {
                     if (strchr($b, "jpg")) {
                         unlink("__photos/__tmp/" . $b);
                     }
                 }
                 break;
         }
     }
 }
Example #9
0
function hg_stop()
{
    $stat = hg_get_status();
    if (!$stat['pid']) {
        error_output('001', '转码已停止');
    }
    $cmd = 'kill -9 ' . $stat['pid'];
    file_put_contents('cmd/' . time(), $cmd);
    if ($_GET['view']) {
        header('Location:?a=view&view=1&auth=' . $_GET['auth']);
    }
    output(array('status' => 1, 'msg' => '转码停止成功'));
}
Example #10
0
$rename = @rename($mp4, $source_file);
if (!$rename) {
    error_output('005', '视频权限限制,无法编辑视频');
}
$mediainfo = new mediainfo($source_file);
$source_file_data = $mediainfo->getMeidaInfo();
$source = array();
foreach ($svodid as $k => $vid) {
    $video_dir = hg_num2dir($vid);
    $targerdir = TARGET_DIR . $video_dir . $vid . '.ssm/';
    if ($vid == $vodid) {
        $sourcef = $source_file;
        $data = $source_file_data;
    } else {
        $sourcef = $targerdir . $vid . '.mp4';
        if (!is_file($sourcef)) {
            error_output('006', '指定片段视频不存在');
        }
        $mediainfo->setFile($sourcef);
        $data = $mediainfo->getMeidaInfo();
    }
    $source[] = array('source' => $sourcef, 'start' => intval($start[$k]), 'duration' => intval($duration[$k]), 'mediainfo' => $data);
}
$curl = new curl($gVodApi['host'], $gVodApi['dir'], $gVodApi['token']);
$curl->initPostData();
$conf = $curl->request('vod_config.php');
$gTransApi['filename'] = 'getVideoInfo.php';
$trans_info = array('sourceFile' => $source, 'id' => $video_id, 'vodid' => $vodid, 'targetDir' => $targerdir, 'config' => $conf[0], 'callback' => $gTransApi);
hg_file_write(UPLOAD_DIR . FILE_QUEUE . $vodid, json_encode($trans_info));
$data = array('id' => $video_id, 'vodid' => $vodid, 'trans_info' => $trans_info);
output($data);
Example #11
0
 public static function sendMail($queueName, $message, $address, $optional = array())
 {
     /** 载入BCMS SDK */
     require_once 'Bcms.class.php';
     $settings = Helper::options()->plugin('CommentToMail');
     $accessKey = $settings->aKey;
     $secretKey = $settings->sKey;
     $host = 'bcms.api.duapp.com';
     if ($accessKey != '' && $secretKey != '') {
         $bcms = new Bcms($accessKey, $secretKey, $host);
     } else {
         $bcms = new Bcms();
     }
     $opt = array(Bcms::FROM => $optional['from'], Bcms::MAIL_SUBJECT => $optional['subject']);
     $ret = $bcms->mail($queueName, $message, $address, $opt);
     if (false === $ret) {
         error_output('ERROR NUMBER: ' . $bcms->errno());
         error_output('ERROR MESSAGE: ' . $bcms->errmsg());
     }
 }
Example #12
0
* 输入: id  视频id
* 返回: 视频转码状态及信息
* 错误返回: 001 - 未指定视频ID, 002 - 未找到视频信息
*/
if (!in_array($_INPUT['auth'], $gToken)) {
    error_output('009', '通信令牌错误');
}
$id = $_INPUT['id'];
if (!$id) {
    error_output('001', '未指定视频ID');
}
$ids = explode(',', $id);
if (count($ids) == 1) {
    $info = getVideoInfoById($ids[0]);
    if (!$info) {
        error_output('002', '未找到视频信息');
    }
    output($info);
}
$info = array();
foreach ($ids as $id) {
    $data = getVideoInfoById($id);
    if (!$data) {
        $data = array('errorno' => '002', 'errortext' => '未找到视频信息');
    }
    $info[] = $data;
}
output($info);
function getVideoInfoById($id)
{
    if (!$id) {
Example #13
0
} elseif ($_INPUT['type'] != 'ismv') {
    $tmp = MP4_TARGET_DIR . $video_dir . $id . '.ssm/' . $id . '.mp4';
    if (is_file($tmp)) {
        $source = $tmp;
    } else {
        $cmd = '/usr/local/bin/mp4split -o ' . $tmp . ' ' . $source;
        $source = UPLOAD_DIR . $video_dir . $id . $filetype;
        hg_mkdir(MP4_TARGET_DIR . $video_dir . $id . '.ssm/');
        exec($cmd);
        if (is_file($tmp)) {
            $source = $tmp;
        }
    }
}
if (!is_file($source)) {
    error_output('004', '视频文件未找到', $source);
}
if (!$stime) {
    $stime = $info['Duration'] / 3;
}
if (!$etime) {
    $etime = $stime;
}
$count = intval($_INPUT['count']);
//截取图片数
$count = $count ? $count : 1;
$dir = ceil($stime / 6000) . '/';
$section = $etime - $stime;
if ($section >= $count) {
    $timestep = intval($section / ($count - 1));
} else {
Example #14
0
if (!$video_id) {
    error_output('001', '未指定视频id');
}
$svodid = $_INPUT['svodid'];
if (!$svodid) {
    error_output('002', '未指定源视频vodid');
}
$start = $_INPUT['start'];
$duration = $_INPUT['duration'];
if (!is_array($svodid)) {
    $svodid = array($svodid);
    $start = array($start);
    $duration = array($duration);
}
if (count($svodid) != count($start) || count($svodid) != count($duration)) {
    error_output('003', '视频信息不匹配');
}
include ROOT_DIR . 'lib/mediainfo.class.php';
$mediainfo = new mediainfo();
$source = array();
foreach ($svodid as $k => $sid) {
    $video_dir = hg_num2dir($sid);
    $targerdir = TARGET_DIR . $video_dir . $sid . '.ssm/';
    $mp4 = $targerdir . $sid . '.mp4';
    $mediainfo->setFile($mp4);
    $data = $mediainfo->getMeidaInfo();
    $source[] = array('source' => $mp4, 'start' => intval($start[$k]), 'duration' => intval($duration[$k]), 'mediainfo' => $data);
}
$file_id = $_INPUT['vodid'];
if (!$file_id) {
    $file_id = hg_get_video_id();
Example #15
0
require ROOT_DIR . 'global.php';
set_time_limit(0);
/**
* 转码控制接口
*
* 输入: videofile  $_FILES文件流
* 返回: json
array(
	'id' => $last_id, //视频id
	'type' => $filetype, //视频类型
	'size' =>  //视频总大小
);
* 错误返回: 001 - 未指定文件传输,002 - 非法的文件类型, 003 - 视频移动失败
*/
if (!in_array($_INPUT['auth'], $gToken)) {
    error_output('009', '通信令牌错误');
}
$content = @file_get_contents(TRANSCODE_STAT);
$info = json_decode($content, true);
if ($info['files']) {
    $script = explode('/', TRANSCODE_SCRIPT);
    $cmd = PSCMD . $script[count($script) - 1];
    exec($cmd, $out, $t);
    $pid = intval($out[0]);
    if (!$pid) {
        include ROOT_DIR . 'lib/mediainfo.class.php';
        $mediainfo = new mediainfo();
        foreach ($info['files'] as $filepath) {
            if (!is_file(UPLOAD_DIR . $filepath)) {
                continue;
            }
Example #16
0
    error_output('002', '非法的视频类型', $_FILES);
}
$video_dir = hg_num2dir($last_id);
if (!hg_mkdir(UPLOAD_DIR . $video_dir) || !is_writeable(UPLOAD_DIR . $video_dir)) {
    error_output('004', UPLOAD_DIR . '目录不可写入文件');
}
if (!hg_mkdir(UPLOAD_DIR . FILE_QUEUE) || !is_writeable(UPLOAD_DIR . FILE_QUEUE)) {
    error_output('004', UPLOAD_DIR . FILE_QUEUE . '目录不可写入文件');
}
$targerdir = TARGET_DIR . $video_dir . $last_id . '.ssm/';
hg_mkdir($targerdir);
$filepath = $video_dir . $last_id . $filetype;
$_INPUT['client'] = intval($_INPUT['client']);
//file_put_contents($targerdir . 'uploading', $filesize . "\n" . $_FILES['videofile']['tmp_name'] . "\n" . UPLOAD_DIR . $filepath);
if (!@move_uploaded_file($_FILES['videofile']['tmp_name'], UPLOAD_DIR . $filepath)) {
    error_output('003', '视频未成功移动到指定目录');
}
include ROOT_DIR . 'lib/mediainfo.class.php';
$mediainfo = new mediainfo(UPLOAD_DIR . $filepath);
$data = $mediainfo->getMeidaInfo();
$snaptime = intval($data['General']['Duration'] / 3);
$snapw = $data['Video']['Width'];
$snaph = $data['Video']['Height'];
$preview = hg_snap($snaptime, $targerdir, $snapw, $snaph, UPLOAD_DIR . $filepath, 0, 'preview');
if ($_INPUT['client'] > -1 && $gVodApi['host']) {
    $vod = array('vodid' => $last_id, 'totalsize' => $filesize, 'type' => $filetype, 'title' => str_replace($filetype, '', $original), 'vod_leixing' => $_INPUT['vod_leixing'] ? $_INPUT['vod_leixing'] : 1, 'admin_id' => $_INPUT['admin_id'], 'admin_name' => $_INPUT['admin_name']);
    $vod['audio'] = $data['Audio']['Format'] . '-' . $data['Audio']['Format profile'] . ' ' . $data['Audio']['Format version'];
    $vod['audio_channels'] = $data['Audio']['Channel positions'];
    $vod['sampling_rate'] = $data['Audio']['Sampling rate'];
    $vod['bitrate'] = $data['General']['Overall bit rate'];
    $vod['duration'] = $data['General']['Duration'];
Example #17
0
* 错误返回: 001 - 未指定视频ID, 002 - 未找到视频信息
*/
if (!in_array($_INPUT['auth'], $gToken)) {
    error_output('009', '通信令牌错误');
}
$id = $_INPUT['id'];
if (!$id) {
    error_output('001', '未指定视频ID');
}
$video_dir = hg_num2dir($id) . $id . '.ssm/';
$mp4 = TARGET_DIR . $video_dir . $id . '.mp4';
$ismv = TARGET_DIR . $video_dir . $id . '.ismv';
if (!is_file($mp4) && is_file($ismv)) {
    $cmd = '/usr/local/bin/mp4split -o ' . $mp4 . ' ' . $ismv;
    hg_mkdir(TARGET_DIR . $video_dir);
    exec($cmd);
}
if (!is_file($mp4)) {
    error_output('002', '视频文件不存在');
} else {
    if ($_INPUT['a'] == 'geturl') {
        $arr = array('url' => THUMB_URL . $video_dir . $id . '.mp4');
        echo json_encode($arr);
        exit;
    }
    $filesize = filesize($mp4);
    header("Content-Type: application/force-download");
    header("Content-Transfer-Encoding: binary\n");
    header('Content-Length: ' . $filesize);
    readfile($mp4);
}
Example #18
0
	'type' => $filetype, //视频类型
	'size' =>  //视频总大小
);
* 错误返回: 001 - 未指定文件传输,002 - 非法的文件类型, 003 - 视频移动失败
*/
if (!in_array($_INPUT['auth'], $gToken)) {
    error_output('009', '通信令牌错误');
}
$stream = $_INPUT['stream'];
$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;