|
@@ -74,4 +74,44 @@ class Api
|
|
|
|
|
|
return $data;
|
|
|
}
|
|
|
+
|
|
|
+ # 解析元信息
|
|
|
+ public function avinfo($data, $url = 'video', $table = 'video/vod')
|
|
|
+ {
|
|
|
+ # 解析视频元信息
|
|
|
+ if (!$data['video_info']) {
|
|
|
+ $video_info = Dever::curl($data[$url] . '?avinfo');
|
|
|
+ if ($video_info) {
|
|
|
+ Dever::db($table)->update(array('where_id' => $data['id'], 'video_info' => $video_info));
|
|
|
+ }
|
|
|
+
|
|
|
+ $video_info = Dever::json_decode($video_info);
|
|
|
+ } else {
|
|
|
+ $video_info = Dever::json_decode($data['video_info']);
|
|
|
+ }
|
|
|
+
|
|
|
+ unset($data['video_info']);
|
|
|
+
|
|
|
+ $data['video_width'] = 0;
|
|
|
+ $data['video_height'] = 0;
|
|
|
+ # 默认横屏
|
|
|
+ $data['video_type'] = 1;
|
|
|
+ if (isset($video_info['streams']) && $video_info['streams']) {
|
|
|
+ foreach ($video_info['streams'] as $k => $v) {
|
|
|
+ if (isset($v['width']) && isset($v['height'])) {
|
|
|
+ $data['video_width'] = $v['width'];
|
|
|
+ $data['video_height'] = $v['height'];
|
|
|
+ if ($data['video_width'] >= $data['video_height']) {
|
|
|
+ $data['video_type'] = 1;
|
|
|
+ } else {
|
|
|
+ $data['video_type'] = 2;
|
|
|
+ }
|
|
|
+
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return $data;
|
|
|
+ }
|
|
|
}
|