Video.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. namespace Content\V1;
  3. use Dever;
  4. class Video
  5. {
  6. # 从腾讯视频中解析mp4
  7. public function show_api($link)
  8. {
  9. $link = $this->mp4_api($link);
  10. $html = '<video controls="controls" width="500" src="'.$link.'">您的浏览器不支持视频播放</video>';
  11. return $html;
  12. }
  13. # 从腾讯视频中解析mp4
  14. public function html_api($link)
  15. {
  16. $url = Dever::url('content/v1/video.show?link=' . $link);
  17. $html = '<a href="#dever_modal" data-toggle="modal" onclick="$.get(\''.$url.'\', function(t)
  18. {
  19. $(\'#dever_modal_body\').html(t);
  20. })">点此播放</a><div style="display:none;">测试</div>';
  21. return $html;
  22. }
  23. # 从腾讯视频中解析mp4
  24. public function mp4_api($link)
  25. {
  26. if (!$link) {
  27. $link = 'https://v.qq.com/x/page/j0515xuxz37.html';
  28. }
  29. $temp = explode('/page/', $link);
  30. if (!isset($temp[1])) {
  31. return $link;
  32. }
  33. $temp = explode('.html', $temp[1]);
  34. $key = $temp[0];
  35. //$key = str_replace(array('https://v.qq.com/x/page/', '.html'), '', $link);
  36. $api = 'http://vv.video.qq.com/getinfo?vids='.$key.'&platform=101001&charge=0&otype=json';
  37. $data = Dever::curl($api);
  38. $data = json_decode(str_replace(array('QZOutputJson=', ';'), '', $data), true);
  39. //print_r($data);die;
  40. $data = $data['vl']['vi'][0];
  41. $urls = $data['ul']['ui'];
  42. foreach ($urls as $k => $v) {
  43. if (strstr($v['url'], 'vhot2.qqvideo.tc.qq.com')) {
  44. $url = $v['url'];
  45. }
  46. }
  47. if (empty($url)) {
  48. return $this->mp4_api($link);
  49. }
  50. $link = $url . $data['fn'] . '?vkey=' . $data['fvkey'];
  51. return $link;
  52. }
  53. //docker run opencoconut/ffmpeg -i http://125.39.7.23/vhot2.qqvideo.tc.qq.com/ABeZbme1SX8-pYwYN_hPTYHdjJsGJiLeTu6P2YfrUsto/j0515xuxz37.m701.mp4?vkey=3EA0D99319B7D7F439F387E804AE9C87C631D0AA8EEE639266754BF3CE14AD55F79CD0239AF29518DBAF415259976CE4767E1615F80CA41B1B12F67067E8A480A95EFD4A6B06767092DFA7252AE16CEE6AC09EBEE4525F423B840B128A7F6522902C1FA8BFC48D0D -f webm -c:v libvpx -c:a libvorbis - > test.webm
  54. }