/** * 获取图片列表显示 */ function show() { $offset = $this->input['offset'] ? intval(urldecode($this->input['offset'])) : 0; $count = $this->input['count'] ? intval(urldecode($this->input['count'])) : 10; $limit = " limit {$offset}, {$count}"; $condition = $this->get_condition(); $sql = 'SELECT p.*,t.title as tuji_title,t.comment,t.path as tuji_path,s.sort_name FROM ' . DB_PREFIX . 'pics p LEFT JOIN ' . DB_PREFIX . 'tuji t ON p.tuji_id = t.id LEFT JOIN ' . DB_PREFIX . 'tuji_sort s ON s.id = t.tuji_sort_id WHERE 1 ' . $condition . ' ORDER BY create_time DESC ' . $limit; $this->setXmlNode('pics', 'pic'); //print_r($this->db->fetch_all($sql)); $q = $this->db->query($sql); while ($r = $this->db->fetch_array($q)) { $r['create_time'] = date('Y-m-d h:i:s', $r['create_time']); $r['update_time'] = date('Y-m-d h:i:s', $r['update_time']); $r['pic_url'] = UPLOAD_ABSOLUTE_URL . hg_num2dir($r['tuji_id']) . $r['new_name']; $r['description'] = $r['description'] ? $r['description'] : (!DESCRIPTION_TYPE ? $r['comment'] : ''); unset($r['comment']); if ($this->input['width'] || $this->input['height']) { $subdir = hg_num2dir($r['tuji_id']) . intval($this->input['width']) . intval($this->input['height']) . '/'; $thumb_dir = UPLOAD_THUMB_DIR . $subdir; if (!is_dir($thumb_dir)) { @hg_mkdir($thumb_dir); } $thumb_file = $this->settings['thumb']['prefix'] . $r['new_name']; $this->gd->init_setting($r['pic_url'], $thumb_dir . $thumb_file); if ($location = $this->gd->makeThumb(1)) { $r['thumb_url'] = UPLOAD_THUMB_URL . $subdir . $thumb_file; } //$r['thumb_url'] = $thumb_dir; } $this->addItem($r); } $this->output(); }
/** * 备播文件列表显示 * @name show * @access public * @author lijiaying * @category hogesoft * @copyright hogesoft * @param $condition 检索条件 * @param $offset 分页参数 * @param $count 分页显示记录数 * @return $r array 所有备播文件内容信息 */ function show() { $offset = $this->input['offset'] ? intval(urldecode($this->input['offset'])) : 0; $count = $this->input['count'] ? intval(urldecode($this->input['count'])) : 20; $limit = " limit {$offset}, {$count}"; $orders = array('id'); $descasc = strtoupper($this->input['hgupdn']); if ($descasc != 'ASC') { $descasc = 'DESC'; } if (in_array($this->input['hgorder'], $orders)) { $orderby = ' ORDER BY ' . $this->input['hgorder'] . ' ' . $descasc; } $condition = $this->get_condition(); $sql = 'SELECT * FROM ' . DB_PREFIX . 'backup WHERE 1' . $condition . $orderby . $limit; $q = $this->db->query($sql); $this->setXmlNode('adv_positions', 'adv_position'); while ($r = $this->db->fetch_array($q)) { $r['create_time'] = date('Y-m-d h:i:s', $r['create_time']); if ($r['toff']) { if (intval($r['toff'] / 1000 / 60)) { $r['toff'] = intval($r['toff'] / 1000 / 60) . "'" . intval(($r['toff'] / 1000 / 60 - intval($r['toff'] / 1000 / 60)) * 60) . '"'; } else { $r['toff'] = intval($r['toff'] / 1000) . '"'; } } if ($r['vodinfo_id']) { // $r['file_uri'] = $this->settings['vod_url'].hg_num2dir($r['vodinfo_id']).$r['vodinfo_id'].VIDEO_MARK_FILE; $r['file_uri'] = $this->settings['vod_url'] . $r['filepath'] . $r['newname']; } else { $r['file_uri'] = UPLOAD_BACKUP_MMS_URL . hg_num2dir($r['id']) . $r['newname']; } $r['img'] = SOURCE_THUMB_PATH . $r['img']; $this->addItem($r); //hg_pre($r); } $this->output(); }
require ROOT_DIR . 'global.php'; /** * 获取视频信息接口 * * 输入: id 视频id * 返回: 视频转码状态及信息 * 错误返回: 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; }
* 返回: 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/'; 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';
<?php define('ROOT_DIR', '../'); require ROOT_DIR . 'global.php'; /** * 获取视频信息接口 * * 输入: 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); $info = array(); foreach ($ids as $id) { $video_dir = TARGET_DIR . hg_num2dir($id); echo 'ls -l ' . $video_dir; exec('ls -l ' . $video_dir, $info, $s); } output($info);
function output($data) { $debug = $_REQUEST['debug']; if (!$debug) { echo json_encode($data); } else { echo '<pre>'; print_r($data); echo '</pre>'; } exit; } $video_id = $_REQUEST['hash']; if (!$video_id) { $error = array('error' => true, 'msg' => '未指定视频流'); output($error); } if ($video_id > 50) { $vprefix = hg_num2dir($video_id); } $adprefix = $_REQUEST['adpre']; $imgprefix = $_REQUEST['imgpre']; $data = json_decode(file_get_contents('config.php'), true); if (is_array($data['preview'])) { foreach ($data['preview'] as $key => $value) { $data['preview'][$key]['url'] = $vprefix . $video_id . '.ssm/preview.jpg'; } } unset($data['program']); $data['program'][] = array('id' => $video_id, 'url' => $vprefix . $video_id . '.ssm/manifest.f4m'); output($data);
public function save_copyright_pic($img, $vodid, $copyright_id) { $dir = hg_num2dir($vodid); $img_path = SOURCE_IMAGE_PATH . $img; $source_img_dir = SOURCE_IMG_DIR . 'copyright/' . $dir; $img_name = 'copyright_' . $copyright_id; $this->get_source_img($img_path, $source_img_dir, $img_name); $sql = " SELECT contents FROM " . DB_PREFIX . "vod_copyright WHERE id = '" . $copyright_id . "'"; $arr = $this->db->query_first($sql); $contents = unserialize($arr['contents']); $contents['img'] = $dir . $img_name . '.jpg'; $info = serialize($contents); $sql = " UPDATE " . DB_PREFIX . "vod_copyright SET contents = '" . $info . "' WHERE id = '" . $copyright_id . "'"; $this->db->query($sql); }
} if ($endtime - $starttime > 86400) { 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);
public function import() { $count = $this->input['count'] ? intval($this->input['count']) : 10; $offset = $this->input['offset'] ? intval($this->input['offset']) : 0; $total = 0; if (file_exists('../cache/vod_total')) { $total = file_get_contents('../cache/vod_total'); } $vod_offset_cache = array(); if (file_exists('../cache/vod_offset_cache')) { $file_handle = fopen('../cache/vod_offset_cache', "r"); while (!feof($file_handle)) { $vod_tmp_offset = intval(fgets($file_handle)); if (!$vod_tmp_offset) { continue; } $vod_offset_cache[] = $vod_tmp_offset; } fclose($file_handle); if (!empty($vod_offset_cache)) { $offset = $vod_offset_cache[count($vod_offset_cache) - 1]; } } define('VIDEO_MARK_FILE', '.ssm/manifest.f4m'); $channel_url = 'http://vapi.thmz.com/liv_mms/admin/channel.php'; $channel_info = json_decode(file_get_contents($channel_url), true); $channel_old = array(); foreach ($channel_info as $k => $v) { $channel_old[$v['id']] = $v['name']; } $channel_new = array(1 => '新闻综合频道', 2 => '娱乐频道', 3 => '都市资讯频道', 4 => '生活频道', 5 => '经济频道', 6 => '移动电视', 7 => '新闻广播', 8 => '综合广播', 9 => '交通频率', 10 => '故事戏曲广播', 11 => '汽车音乐频率', 12 => '江南之声频率', 13 => '都市生活频率', 14 => '经济频率', 20 => '广播新年音乐会'); $channel_relation = array(1 => 1, 2 => 3, 3 => 2, 4 => 5, 5 => 4, 6 => 6, 7 => 1, 9 => 7, 10 => 8, 11 => 9, 12 => 10, 13 => 11, 14 => 12, 15 => 13, 16 => 14, 17 => 9); /* 1、频道对应关系 2、类型对应关系 3、根据视频id获许视频地址 4、标注视频所发布的栏目抓取 5、视频缩略图抓取 */ $sort_new = array('第一网谈' => 29, '庭审在线' => 30, '活动直播' => 20); $cache = file_get_contents('../cache/column_cache'); $cache_array = explode('--------------', $cache); $column_cache = array(); foreach ($cache_array as $k => $v) { if ($v) { $tmp_cache = explode('**', $v); $column_cache[$tmp_cache[0]] = $tmp_cache[1]; } } //hg_pre($column_cache);exit; $vod_total_url = 'http://vapi.thmz.com/liv_mms/admin/vod.php?_type=1&a=count'; $vod_total = json_decode(file_get_contents($vod_total_url), true); if (empty($offset)) { $offset = $vod_total['total'] - $count; } else { $offset = $offset - $count; } $extra_url = '?appid=' . $this->input['appid'] . '&appkey=' . $this->input['appkey'] . '&access_token=' . $this->input['access_token']; $limit = "&count=" . $count . '&offset=' . $offset; $to_url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . $extra_url . $limit; $vod_url = 'http://vapi.thmz.com/liv_mms/admin/vod.php?_type=1' . $limit; $vod_data = file_get_contents($vod_url); if ($vod_data) { $vod_info = json_decode($vod_data, true); $vod_id = $space = ""; foreach ($vod_info as $k => $v) { $vod_id .= $space . $v['id']; $space = ','; $total++; } //hg_pre($vod_info); file_put_contents('../cache/vod_total', $total); if ($vod_id) { $sql = "SELECT * FROM " . DB_PREFIX . "import_queue WHERE old_id IN(" . $vod_id . ")"; $q = $this->db->query($sql); $vod_info_queue = array(); while ($row = $this->db->fetch_array($q)) { $vod_info_queue[] = $row['old_id']; } $publish_vod_id = $space = ''; $vod_info_publish = array(); $sort_new = array_flip($sort_new); foreach ($vod_info as $k => $v) { if (!in_array($v['id'], $vod_info_queue) && in_array($v['vod_sort_id'], $sort_new)) { $v['img'] = $v['img'] ? str_replace('thumb/100X200/', '', $v['img']) : ''; $publish_vod_id .= $space . $v['id']; $space = ','; $vod_info_publish[] = $v; } } $sort_new = array_flip($sort_new); if ($publish_vod_id) { $vod_info = array(); $vod_info = $vod_info_publish; krsort($vod_info); $this->curl->setSubmitType('post'); $this->curl->setReturnFormat('json'); $this->curl->initPostData(); $this->curl->addRequestData('a', 'show'); $this->curl->addRequestData('site_id', 2); $this->curl->addRequestData('count', 200); $this->curl->addRequestData('access_token', 'e5069162db4e5b411971c48ac21f5829'); $column_ret = $this->curl->request('column.php'); $column_new = array(); foreach ($column_ret as $k => $v) { $column_new[$v['id']] = $v['name']; } // hg_pre($column_new);exit; $publish_url = 'http://vapi.thmz.com/workbench/publish.php?id=' . $publish_vod_id; $publish_column = json_decode(file_get_contents($publish_url), true); // hg_pre($publish_column); $publish_vod_id = array(); if (!empty($publish_column)) { foreach ($publish_column as $k => $v) { $publish_vod_id[] = $k; } } $import_queue = array(); $cache_show = array(); //hg_pre($vod_info);exit; foreach ($vod_info as $k => $v) { if (in_array($v['id'], $publish_vod_id)) { $tmp_duration = explode('’', $v['duration']); if (count($tmp_duration) == 2) { $v['duration'] = (intval($tmp_duration[0]) * 60 + intval($tmp_duration[1])) * 1000; } else { $v['duration'] = intval($tmp_duration[1]) * 1000; } $data = array('title' => $v['title'], 'channel_id' => $channel_relation[$v['channel_id']], 'source' => $channel_new[$channel_relation[$v['channel_id']]], 'subtitle' => $v['subtitle'], 'keywords' => $v['keywords'], 'comment' => $v['comment'], 'author' => $v['author'], 'vcr_type' => 4, 'type' => $v['type'], 'duration' => $v['duration'], 'height' => $v['height'], 'isfile' => $v['isfile'], 'start' => $v['start'], 'width' => $v['width'], 'totalsize' => $v['totalsize'], 'vod_sort_id' => $sort_new[$v['vod_sort_id']], 'is_allow' => $v['is_allow'], 'column_id' => 0, 'from_appid' => 1, 'from_appname' => 'MCP网页版', 'user_id' => 1, 'addperson' => 'hogesoft', 'hostwork' => defined("TARGET_VIDEO_DOMAIN") ? 'http://' . ltrim(TARGET_VIDEO_DOMAIN, 'http://') : $this->settings['videouploads']['protocol'] . $this->settings['videouploads']['host'], 'video_path' => hg_num2dir($v['vodid']) . $v['vodid'] . '.ssm/', 'video_filename' => $v['vodid'] . '.mp4', 'source_path' => '', 'source_filename' => '', 'bitrate' => $v['bitrate'], 'vod_leixing' => 4, 'create_time' => strtotime($v['create_time']), 'update_time' => strtotime($v['update_time']), 'ip' => $v['ip'], 'pub_time' => 0, 'is_allow' => 0, 'is_finish' => 0, 'status' => 2, 'technical_status' => 3, 'audio' => $v['audio'], 'audio_channels' => $v['audio_channels'], 'sampling_rate' => $v['sampling_rate'], 'video' => $v['video'], 'frame_rate' => $v['frame_rate'], 'aspect' => $v['aspect']); if ($publish_column[$v['id']]) { foreach ($publish_column[$v['id']] as $kk => $vv) { $data['column_id'] = serialize(array($column_cache[$kk] => $column_new[$column_cache[$kk]])); } } $tmp_path = $data['video_path']; $data['video_path'] = 'former/' . $data['video_path']; $sql = " INSERT INTO " . DB_PREFIX . "vodinfo SET "; foreach ($data as $ks => $vs) { $sql .= " {$ks} = '{$vs}',"; } $sql = trim($sql, ','); $this->db->query($sql); $vid = $this->db->insert_id(); $import_queue[$v['id']] = $vid; $pic_path = $v['img']; if ($pic_path) { $img_info = $this->image2material($pic_path, $vid); $image_info = array('host' => $img_info['host'], 'dir' => $img_info['dir'], 'filepath' => $img_info['filepath'], 'filename' => $img_info['filename']); $sql = " UPDATE " . DB_PREFIX . "vodinfo SET video_order_id = {$vid},img_info = '" . serialize($image_info) . "' WHERE id = {$vid}"; $this->db->query($sql); } $sql = "INSERT INTO " . DB_PREFIX . "import_queue(old_id,new_id) VALUES (" . $v['id'] . "," . $vid . ")"; $this->db->query($sql); // $cache_show[] = $data; //复制物理文件 $vdir = '/iptvstorage/webroot/vod/' . $tmp_path; $idir = '/vstorage/vod/mp4/former/' . $tmp_path; if (hg_mkdir($idir)) { @copy($vdir . $v['vodid'] . '.ism', $idir . $v['vodid'] . '.ism'); @copy($vdir . $v['vodid'] . '.ismv', $idir . $v['vodid'] . '.ismv'); } } } file_put_contents('../cache/vod_offset_cache', $offset . "\n", FILE_APPEND); } else { file_put_contents('../cache/vod_offset_cache', $offset . "\n", FILE_APPEND); } } else { file_put_contents('../cache/vod_offset_cache', $offset . "\n", FILE_APPEND); } } else { file_put_contents('../cache/vod_offset_cache', $offset . "\n", FILE_APPEND); echo "总计" . $total . "条,完成导入"; } }
function getVideoInfoById($id) { if (!$id) { return false; } $time = 0; $video_dir = hg_num2dir($id); include ROOT_DIR . 'lib/mediainfo.class.php'; $mediainfo = new mediainfo(MP4_TARGET_DIR . $video_dir . $id . '.ssm/' . $id . '.mp4'); $data = $mediainfo->getMeidaInfo(); $sourceinfo = @file_get_contents(MP4_TARGET_DIR . $video_dir . $id . '.ssm/source_media_info'); $sourceinfo = json_decode($sourceinfo, true); if (!$data && !$sourceinfo) { $_INPUT['status'] = -1; hg_update_vod(array(), '', ''); return false; } $info = array(); $targerdir = MP4_TARGET_DIR . $video_dir . $id . '.ssm/'; $info['id'] = $id; $out = @file_get_contents(MP4_TARGET_DIR . $video_dir . $id . '.ssm/out'); // frame=20302 fps= 17 q=14.0 size= 272224kB time=2582.58 bitrate= 863.5kbits/s dup=0 drop=39852 //duplicate frame(s)!Pos:5193.4s 129587f (99%) 263.62fps Trem: 0min 574mb A-V:0.029 [687:236] preg_match_all('/frame=\\s*\\d*\\s*fps=\\s*\\d*\\s*q=\\s*[0-9\\.]*\\s*size=\\s*(\\d*)kB\\s*time=\\s*([0-9\\.]*)\\s*bitrate=\\s*([0-9\\.]*)/is', $out, $result); preg_match_all('/frame=\\s*\\d*\\s*fps=\\s*\\d*\\s*q=\\s*[0-9\\.\\-]*\\s*Lsize=\\s*(\\d*)/is', $out, $complete); preg_match_all('/\\(([\\d\\.]*)%\\)/is', $out, $mecoder); $mecoder = $mecoder[1]; $mecoder_progress = $mecoder[count($mecoder) - 1]; $count = count($result[0]) - 1; //print_r($result); $progress = $result[1][$count]; $curtime = $result[2][$count]; $curbitrate = $result[3][$count]; $complete = $complete[1][0]; $info['audio'] = $data['Audio']['Format'] . '-' . $data['Audio']['Format profile'] . ' ' . $data['Audio']['Format version']; $info['audio_channels'] = $data['Audio']['Channel positions']; $info['sampling_rate'] = $data['Audio']['Sampling rate']; $info['bitrate'] = $data['General']['Overall bit rate']; $info['duration'] = $data['General']['Duration']; $info['video'] = $data['Video']['Format'] . ' ' . $data['Video']['Format profile']; $info['width'] = $data['Video']['Width']; $info['height'] = $data['Video']['Height']; $info['aspect'] = $data['Video']['Display aspect ratio']; $info['frame_rate'] = $data['Video']['Frame rate']; $info['img_src'] = THUMB_URL . $video_dir . $id . '.ssm/preview.jpg'; $info['transize'] = $progress * 1024; $info['status'] = 0; //print_r($sourceinfo); if ($complete) { $info['status'] = 1; //转码完成 $progress = $complete; $info['totalsize'] = $data['General']['File size']; } else { if (!$curbitrate) { $curbitrate = 70; } else { $curbitrate = $curbitrate / 8; } $speed = $curbitrate; $info['totalsize'] = $sourceinfo['General']['Duration'] * $curbitrate / 1000 * 1024; } if ($mecoder_progress && !$info['transize']) { $info['totalsize'] = $info['totalsize'] + $sourceinfo['General']['File size']; $info['transize'] = intval($sourceinfo['General']['File size'] * (100 - $mecoder_progress) / 100); $speed = mt_rand(20, 120); } $info['speed'] = $speed; $info['mecoder_progress'] = $mecoder_progress; $mediainfo_file = $targerdir . 'media_info'; hg_file_write($mediainfo_file, json_encode($data)); $file = $targerdir . $id . '.mp4'; if (is_file($file)) { $mp4 = THUMB_URL . $video_dir . $id . '.ssm/' . $id . '.mp4'; } hg_update_vod($info, $mp4, $video_dir . $id . '.ssm/'); return $info; }
/** * 创建备播文件 * @name create * @access public * @author lijiaying * @category hogesoft * @copyright hogesoft * @param $vodinfo_id int 视屏集合ID * @param $img string 图片路径 * @param $title string 标题 * @param $brief string 描述 * @param $toff int 时长 * @param $user_name string 用户名 * @param $create_time int 创建时间 * @param $update_time int 更新时间 * @param $ip string 创建者ID * @param $filename string 源文件名 * @param $filepath string 文件路径 * @param $newname string 上传后文件新名称 * @return $ret int 备播文件ID */ function create() { $title = $this->input['title']; if (!$title) { $this->errorOutput('标题不能为空'); } $vodinfo_id = intval($this->input['back_up_video_id']); if ($vodinfo_id) { // $sql = "SELECT * FROM " . DB_PREFIX . "vodinfo WHERE id=" .$vodinfo_id; // $video_info = $this->db->query_first($sql); $video_info = $this->getVodInfoById($vodinfo_id); if (empty($video_info)) { return false; } $vodid_info = $this->vodid_info($video_info['vodid']); if (empty($vodid_info)) { return false; } $filename = $video_info['title']; $toff = $video_info['duration']; $filepath = $vodid_info['filepath']; $newname = $vodid_info['filename']; } else { if ($_FILES['backup_file']['error'] !== 0) { $this->errorOutput(NOUPLOADFILE); } $suffix = explode('.', $_FILES['backup_file']['name']); $suffix = $suffix[count($suffix) - 1]; if (strtolower($suffix) != UPLOAD_BACKUP_MMS_FILE_TYPE) { $this->errorOutput(FILE_TYPE_NOT_SURPPORT); } $filename = $_FILES['backup_file']['name']; $newname = microtime(true) . '.' . UPLOAD_BACKUP_MMS_FILE_TYPE; } $data = array('vodinfo_id' => $vodinfo_id, 'img' => urldecode($video_info['img']), 'title' => trim(urldecode($this->input['title'])), 'brief' => trim(urldecode($this->input['brief'])), 'toff' => $toff, 'user_name' => $this->user['user_name'], 'create_time' => TIMENOW, 'update_time' => TIMENOW, 'filename' => $filename, 'newname' => $newname, 'filepath' => $filepath, 'ip' => hg_getip()); $sql = 'INSERT INTO ' . DB_PREFIX . 'backup SET '; foreach ($data as $k => $v) { $sql .= $k . '="' . $v . '",'; } $sql = rtrim($sql, ','); $this->db->query($sql); $ret = $this->db->insert_id(); if (!$vodinfo_id) { $dir = UPLOAD_DIR . 'backup_mms/' . hg_num2dir($ret); if (!is_dir($dir)) { hg_mkdir($dir); } $target_file = $dir . $data['newname']; if (!move_uploaded_file($_FILES['backup_file']['tmp_name'], $target_file)) { $this->errorOutput(MOVEFILEFAILED); } } $this->addItem($ret); $this->output(); }
/** * 获取所有备播文件 * @name get_all_beibo_files * @access public * @author lijiaying * @category hogesoft * @copyright hogesoft * @return $r array 所有备播文件信息 */ public function get_all_beibo_files() { $sql = "SELECT * FROM " . DB_PREFIX . 'backup WHERE 1'; $q = $this->db->query($sql); while ($r = $this->db->fetch_array($q)) { if ($r['vodinfo_id']) { $r['beibo_file_url'] = $this->settings['vod_url'] . $r['filepath'] . $r['newname']; } else { $r['beibo_file_url'] = UPLOAD_BACKUP_MMS_URL . hg_num2dir($r['id']) . $r['newname']; } if ($r['toff']) { if (intval($r['toff'] / 1000 / 60)) { $r['toff'] = intval($r['toff'] / 1000 / 60) . "'" . intval(($r['toff'] / 1000 / 60 - intval($r['toff'] / 1000 / 60)) * 60) . '"'; } else { $r['toff'] = intval($r['toff'] / 1000) . '"'; } } $this->addItem($r); } $this->output(); }
} 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(); } $dir = hg_num2dir($file_id); $video_dir = hg_num2dir($file_id); $targerdir = TARGET_DIR . $video_dir . $file_id . '.ssm/'; hg_mkdir($targerdir); $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' => $file_id, 'targetDir' => $targerdir, 'config' => $conf[0], 'callback' => $gTransApi); hg_file_write(UPLOAD_DIR . FILE_QUEUE . $file_id, json_encode($trans_info)); $data = array('vodid' => $file_id, 'cmd' => $cmd, 'trans_info' => $trans_info, 'target' => $targerdir); output($data);
define('ROOT_DIR', '../'); require ROOT_DIR . 'global.php'; /** * 获取视频信息接口 * * 输入: 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); $info = array(); foreach ($ids as $id) { $video_dir = TARGET_DIR . hg_num2dir($id) . $id . '.ssm/'; $delete_video_dir = TARGET_DIR . hg_num2dir($id) . 'deleted_' . $id . '.ssm/'; $r = @rename($video_dir, $delete_video_dir); if (!$r) { $id = 0; } if (WOWZA_DIR) { @unlink(WOWZA_DIR . $id . '.mp4'); } $info[] = $id; } output($info);
public function delete_pics($tuji_id) { if (!$tuji_id) { return; } $tuji_id = explode(',', $tuji_id); foreach ($tuji_id as $id) { $dir = UPLOAD_ROOT_DIR . hg_num2dir($id); $files = scandir($dir); if (!is_array($files)) { continue; } foreach ($files as $v) { if ($v != '.' && $v != '..') { if (is_dir($dir . $v)) { continue; } @unlink($dir . $v); } } } }