视频储存是很多人的一个难题…自己买个服务器又需要带宽有需要硬盘够大! 看看怎么是一个完美的存储. 我也是偶然发现的。把视频切片成 m3u8 之后,视频会变成一段段的 ts 格式的视频。这个时候我想了一下。如果说某些图床又 bug 不验证文件格式,那么是不是就可以把切片视频放在他的服务器上进行播放了? 嘿嘿,没想到真的可以。当当当~ 他就是某里的“图床”。 这个其实不是什么图床,是某巴客服中一个漏洞,稳定几年了,很多什么图床网站就是用这个接口 有了方案我们就试试吧。其实还要很多,不止这一个地方哦~!嘿嘿~这个PHP文件有个小小的BUG我在这里就不帮你们修复了, 第18行 丢帧的问题,丢的严重
<?php $v_path = $argv[1]; //切片路径 $v_name = $argv[2]; //带切片的视频路径名称 $s = 5; //切片秒 ts 切片必须小于 5MB if (empty($v_path) || empty($v_name)) { echo "请填写完整参数"; exit; } if ($v_path == '/' || $v_path == '\\') { $v_path = ''; } else { mkFolder($v_path); $v_path = $v_path . "/"; } //这是 FFmpeg 处理命令大家自行更改 exec("ffmpeg -i $v_name -c copy -map 0 -f segment -segment_list " . $v_path . "playlist.m3u8 -segment_time $s " . $v_path . "player%03d.ts"); $m = file_get_contents('./' . $v_path . 'playlist.m3u8'); preg_match_all('/player(.*?)\.ts/', $m, $arr); foreach ($arr[1] as $key => $value) { echo "处理第" . $value . '个切片' . "\n"; $ali = upload('./' . $v_path . 'player' . $value . '.ts'); $m = str_replace('player' . $value . '.ts', $ali, $m); file_put_contents('./' . $v_path . 'play.m3u8', $m); } echo "处理完毕" . "\n"; echo "播放链接为:/" . $v_path . 'play.m3u8'; function upload($file) { $post['file'] = file_path($file); $post['scene'] = 'aeMessageCenterV2ImageRule'; $post['name'] = 'player.jpg'; $rel = get_curl('https://kfupload.alibaba.com/mupload', $post, 'iAliexpress/6.22.1 (iPhone; iOS 12.1.2; Scale/2.00)'); $rel = json_decode($rel, true); return $rel['url']; } function get_curl($url, $post = 0, $ua = 0) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); // 不验证证书 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); // 最大执行时间 curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 120); curl_setopt($ch, CURLOPT_TIMEOUT, 120); $httpheader[] = "Accept:application/json"; $httpheader[] = "Accept-Encoding:gzip,deflate,sdch"; $httpheader[] = "Accept-Language:zh-CN,zh;q=0.8"; $httpheader[] = "Connection:close"; $ip = mt_rand(48, 140) . "." . mt_rand(10, 240) . "." . mt_rand(10, 240) . "." . mt_rand(10, 240); //随机 ip $httpheader[] = 'CLIENT-IP:' . $ip; $httpheader[] = 'X-FORWARDED-FOR:' . $ip; curl_setopt($ch, CURLOPT_HTTPHEADER, $httpheader); if ($post) { curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $post); } if ($ua) { curl_setopt($ch, CURLOPT_USERAGENT, $ua); } else { curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Linux; U; Android 4.0.4; es-mx; HTC_One_X Build/IMM76D) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0"); } curl_setopt($ch, CURLOPT_ENCODING, "gzip"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $ret = curl_exec($ch); curl_close($ch); return $ret; } function mkFolder($path) { if (!is_readable($path)) { is_file($path) or mkdir($path, 0700); } } function file_path($file) { if (class_exists('CURLFile')) { return $post['file'] = new \CURLFile(realpath($file)); } else { return $post['file'] = '@' . realpath($file); } }
这个接口只能上次小于 5MB 以下的图片(视频切片)所以切片完文件大小必须小于 5MB,还有就是 PHP 本身就不适合写脚本,单线程处理,很慢.建议用 PY 或者 java
发表评论