5ep9lzv 发表于 2024-10-4 19:11:22

[精选] php亦是能够做直播相关业务研发的


    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><strong style="color: blue;"><span style="color: black;">商务合作加<span style="color: black;">微X</span>:2230304070&nbsp;</span></strong></span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><strong style="color: blue;"><span style="color: black;">学习与交流:</span></strong><span style="color: black;"><strong style="color: blue;"><span style="color: black;"><a style="color: black;">PHP技术交流<span style="color: black;">微X</span>群&nbsp;</a></span></strong></span></span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><strong style="color: blue;">学习与分享:</strong><strong style="color: blue;"><a style="color: black;">JetBrains 正版授权 ,<span style="color: black;">所有</span>系列 IDE 均可用</a></strong></span></p><span style="color: black;">如今的直播平台到处都是了,自己动手用PHP去做一个视频直播,那是<span style="color: black;">能够</span>的,你<span style="color: black;">能够</span>用到swoole。<span style="color: black;"><span style="color: black;">然则</span>会花很<span style="color: black;">长期</span>去<span style="color: black;">研发</span>与测试吧!<span style="color: black;">亦</span>不<span style="color: black;">晓得</span><span style="color: black;">研发</span>出来的效果会不会不稳定。</span></span><span style="color: black;"><span style="color: black;"><span style="color: black;">因此</span>为了节省<span style="color: black;">更加多</span>的时间,<span style="color: black;">研发</span>视频直播基本都会用到第三方稳定的API,今天要讲到的是用PHP与阿里云视频直播API<span style="color: black;">研发</span>视频直播</span></span><span style="color: black;"><strong style="color: blue;"><span style="color: black;">swoole做直播<span style="color: black;">详细</span><span style="color: black;">过程</span>如下:(带摄像头的笔记本)</span></strong></span><span style="color: black;">1、Swoole创建 2个监听 一个WebSocket监听服务(用于视频流传输)。一个本地 【Unix Socket文件描述符】(用于ffmpeg转码后的视频流接受与转发给WebSocket客户端。)</span><span style="color: black;">2、浏览器<span style="color: black;">运用</span> jsmpeg 这个项目连接 Swoole <span style="color: black;">供给</span>的WebSocket 服务来获取视频流播放。</span><span style="color: black;">3、<span style="color: black;">运用</span>ffmpeg 把直播的视频流 转码 为 mpeg 视频流格式 发送到 本地的Swoole 监听的【Unix Socket】文件描述符</span><span style="color: black;"><span style="color: black;">例如</span>:$serv-&gt;addlistener("/var/run/myserv.sock", 0,SWOOLE_UNIX_STREAM); 文件描述符:/var/run/myserv.sock</span><span style="color: black;">4、Swoole 监听的文件描述符 的 onReceive 事件会收到 ffmpeg 转码的视频流。在<span style="color: black;">经过</span> Swoole的WebSocket<span style="color: black;">办法</span>push 给连接到 WebSocket服务的 客户端发送视频流。</span><span style="color: black;"><strong style="color: blue;"><span style="color: black;">PHP与阿里云视频直播API<span style="color: black;">研发</span>视频直播</span></strong></span><strong style="color: blue;"><span style="color: black;">1.下载sdk放入项目文件夹中</span></strong><img src="https://mmbiz.qpic.cn/mmbiz_png/QibLP1rpwH8tPARmHkaYNLePxCHhGqNxCcUPkqa39StsOQRupab2kXcrBZyyIC3Y1n6yy7AuQWK03USHfbDoj3g/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" style="width: 50%; margin-bottom: 20px;"><img src="https://mmbiz.qpic.cn/mmbiz_png/QibLP1rpwH8tPARmHkaYNLePxCHhGqNxC5fUw1D88YiaibZiaXTvG7Bib5XmmkqTAv3WxKh7iaEKjnibiaqicZNHrlb0stQ/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" style="width: 50%; margin-bottom: 20px;"><img src="https://mmbiz.qpic.cn/mmbiz_png/QibLP1rpwH8tPARmHkaYNLePxCHhGqNxCoKbsySwhGjuHTvaNzCnicjiafL9R9VOnbwZcMY7G9J8hjNJghtaN3p0g/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" style="width: 50%; margin-bottom: 20px;"><span style="color: black;">核心<span style="color: black;">便是</span>aliyun-php-sdk-core,它的配置文件会自动加载相应的类</span><strong style="color: blue;"><span style="color: black;">2.引入文件</span></strong><span style="color: black;">include_once</span>&nbsp;LIB_PATH&nbsp;.&nbsp;<span style="color: black;">ORG/aliyun-openapi/aliyun-php-sdk-core/Config.php</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">;</p><strong style="color: blue;"><span style="color: black;">3.配置客户端对象,需要Access Key ID,Access Key Secret</span></strong>$iClientProfile&nbsp;=&nbsp;DefaultProfile::getProfile(<span style="color: black;">"cn-hangzhou"</span>,&nbsp;<span style="color: black;">"xxxx"</span>,&nbsp;<span style="color: black;">"xxxx"</span>);&nbsp;&nbsp;<span style="color: black;">//&nbsp;Access&nbsp;Key&nbsp;ID,Access&nbsp;Key&nbsp;Secret</span>$client&nbsp;=&nbsp;<span style="color: black;">new</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;DefaultAcsClient($iClientProfile);</p><strong style="color: blue;"><span style="color: black;">4.调用请求类,并配置参数,就拿直播推流历史为例</span></strong>$request&nbsp;=&nbsp;<span style="color: black;">new</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">live\Request\V20161101\DescribeLiveStreamsPublishListRequest();</p>$request&nbsp;-&gt;setDomainName(<span style="color: black;">live.yunlutong.com</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">);</p>$request&nbsp;-&gt;setAppName(<span style="color: black;">yunlutong</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">);</p>$request&nbsp;-&gt;setStreamName(<span style="color: black;">demo</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">);</p>$request&nbsp;-&gt;setStartTime(<span style="color: black;">2020-03-01T19:00:00Z</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">);</p>$request&nbsp;-&gt;setEndTime(<span style="color: black;">2020-03-29T19:00:00Z</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">);</p><strong style="color: blue;"><span style="color: black;">5.发起请求</span></strong><span style="color: black;">//针对阿里云进行请求</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">$response&nbsp;=&nbsp;$client-&gt;getAcsResponse($request);</p><span style="color: black;">exit</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">(json_encode($response));</p><strong style="color: blue;">完整代码如下</strong><span style="color: black;"><span style="color: black;">&lt;?php</span><span style="color: black;">
            <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">/**</p>
            <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;*&nbsp;直播<span style="color: black;">关联</span>接口</p>&nbsp;*/
      </span><span style="color: black;"><span style="color: black;">class</span>&nbsp;<span style="color: black;">LiveAction</span>&nbsp;<span style="color: black;">extends</span>&nbsp;<span style="color: black;">ApiAction</span></span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">{</p>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: black;">protected</span>&nbsp;<span style="color: black;"><span style="color: black;">function</span>&nbsp;<span style="color: black;">_initialize</span><span style="color: black;">()</span>&nbsp;&nbsp;&nbsp;&nbsp;</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">{</p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: black;">parent</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">::_initialize();</p>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;&nbsp;&nbsp;}</p>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: black;">//&nbsp;获取推流历史</span>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: black;">public</span>&nbsp;<span style="color: black;"><span style="color: black;">function</span>&nbsp;<span style="color: black;">DescribeLiveStreamsPublishList</span><span style="color: black;">()</span>&nbsp;</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">{</p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: black;">include_once</span>&nbsp;LIB_PATH&nbsp;.&nbsp;<span style="color: black;">ORG/aliyun-openapi/aliyun-php-sdk-core/Config.php</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">;</p>$iClientProfile&nbsp;=&nbsp;DefaultProfile::getProfile(<span style="color: black;">"cn-hangzhou"</span>,&nbsp;<span style="color: black;">"xxxx"</span>,&nbsp;<span style="color: black;">"xxxx"</span>);&nbsp;&nbsp;<span style="color: black;">//&nbsp;Access&nbsp;Key&nbsp;ID,Access&nbsp;Key&nbsp;Secret</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$client&nbsp;=&nbsp;<span style="color: black;">new</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;DefaultAcsClient($iClientProfile);</p>$request&nbsp;=<span style="color: black;">new</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;live\Request\V20161101\DescribeLiveStreamsPublishListRequest();</p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$request&nbsp;-&gt;setDomainName(<span style="color: black;">live.yunlutong.com</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">);</p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$request&nbsp;-&gt;setAppName(<span style="color: black;">yunlutong</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">);</p>$request&nbsp;-&gt;setStreamName(<span style="color: black;">demo</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">);</p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$request&nbsp;-&gt;setStartTime(<span style="color: black;">2020-03-01T19:00:00Z</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">);</p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$request&nbsp;-&gt;setEndTime(<span style="color: black;">2020-03-29T19:00:00Z</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">);</p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: black;">//针对阿里云进行请求</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">$response&nbsp;=&nbsp;$client-&gt;getAcsResponse($request);</p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: black;">exit</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">(json_encode($response));</p>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;&nbsp;&nbsp;}</p>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">}</p>
    </span><span style="color: black;">返回的数据</span><img src="https://mmbiz.qpic.cn/mmbiz_png/QibLP1rpwH8tPARmHkaYNLePxCHhGqNxCa2spanFIcM0MguKXuL7J1B2Ut4vw1nzlzZmhb8FBKjRoUxtSAwf8Nw/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" style="width: 50%; margin-bottom: 20px;"><span style="color: black;">其他的接口请求<span style="color: black;">亦</span>都类似<span style="color: black;">这般</span>,就不在<span style="color: black;">这儿</span>一一列举,<span style="color: black;">更加多</span>会用到的API,你是要查看API文档的,<span style="color: black;">位置</span>:https://help.aliyun.com/document_detail/48207.html</span>
    <h1 style="color: black; text-align: left; margin-bottom: 10px;"><span style="color: black;">视频直播生成推流<span style="color: black;">位置</span>和播放<span style="color: black;">位置</span>的程序示例</span></h1><span style="color: black;">直播推流<span style="color: black;">位置</span>和播放<span style="color: black;">位置</span>本身<span style="color: black;">无</span>API接口,需要在客户端<span style="color: black;">自动</span>拼接<span style="color: black;">位置</span>,<span style="color: black;">而后</span><span style="color: black;">运用</span>推流工具<span style="color: black;">或</span>播放器对其推流或播放。</span><span style="color: black;">示例代码</span><span style="color: black;"><span style="color: black;">&lt;?php</span><span style="color: black;"><span style="color: black;">function</span>&nbsp;<span style="color: black;">push_url</span><span style="color: black;">($push_domain,$push_key,$expireTime,$appName,$streamName)</span></span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">{</p>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$push_url&nbsp;=&nbsp;;</p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: black;">//未开启鉴权Key的<span style="color: black;">状况</span>下</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: black;">if</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">($push_key==){</p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$push_url&nbsp;=&nbsp;<span style="color: black;">rtmp://</span>.$push_domain.<span style="color: black;">/</span>.$appName.<span style="color: black;">/</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">.$streamName;</p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: black;">echo</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;$push_url;</p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: black;">return</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">;</p>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</p>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">$timeStamp&nbsp;=&nbsp;time()&nbsp;+&nbsp;$expireTime;</p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$sstring&nbsp;=&nbsp;<span style="color: black;">/</span>.$appName.<span style="color: black;">/</span>.$streamName.<span style="color: black;">-</span>.$timeStamp.<span style="color: black;">-0-0-</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">.$push_key;</p>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$md5hash&nbsp;=&nbsp;md5($sstring);</p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$push_url&nbsp;=&nbsp;<span style="color: black;">rtmp://</span>.$push_domain.<span style="color: black;">/</span>.$appName.<span style="color: black;">/</span>.$streamName.<span style="color: black;">?auth_key=</span>.$timeStamp.<span style="color: black;">-0-0-</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">.$md5hash;</p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: black;">echo</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;$push_url;</p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: black;">echo</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;PHP_EOL;</p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: black;">return</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">;</p>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">}</p><span style="color: black;"><span style="color: black;">function</span>&nbsp;<span style="color: black;">play_url</span><span style="color: black;">($play_domain,$play_key,$expireTime,$appName,$streamName)</span></span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">{</p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: black;">//未开启鉴权Key的<span style="color: black;">状况</span>下</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: black;">if</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">($play_key==){</p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$rtmp_play_url&nbsp;=&nbsp;<span style="color: black;">rtmp://</span>.$play_domain.<span style="color: black;">/</span>.$appName.<span style="color: black;">/</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">.$streamName;</p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$flv_play_url&nbsp;=&nbsp;<span style="color: black;">http://</span>.$play_domain.<span style="color: black;">/</span>.$appName.<span style="color: black;">/</span>.$streamName.<span style="color: black;">.flv</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">;</p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$hls_play_url&nbsp;=&nbsp;<span style="color: black;">http://</span>.$play_domain.<span style="color: black;">/</span>.$appName.<span style="color: black;">/</span>.$streamName.<span style="color: black;">.m3u8</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">;</p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<span style="color: black;">else</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">{</p>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$timeStamp&nbsp;=&nbsp;time()&nbsp;+&nbsp;$expireTime;</p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$rtmp_sstring&nbsp;=&nbsp;<span style="color: black;">/</span>.$appName.<span style="color: black;">/</span>.$streamName.<span style="color: black;">-</span>.$timeStamp.<span style="color: black;">-0-0-</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">.$play_key;</p>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$rtmp_md5hash&nbsp;=&nbsp;md5($rtmp_sstring);</p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$rtmp_play_url&nbsp;=&nbsp;<span style="color: black;">rtmp://</span>.$play_domain.<span style="color: black;">/</span>.$appName.<span style="color: black;">/</span>.$streamName.<span style="color: black;">?auth_key=</span>.$timeStamp.<span style="color: black;">-0-0-</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">.$rtmp_md5hash;</p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$flv_sstring&nbsp;=&nbsp;<span style="color: black;">/</span>.$appName.<span style="color: black;">/</span>.$streamName.<span style="color: black;">.flv-</span>.$timeStamp.<span style="color: black;">-0-0-</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">.$play_key;</p>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$flv_md5hash&nbsp;=&nbsp;md5($flv_sstring);</p>$flv_play_url&nbsp;=<span style="color: black;">http://</span>.$play_domain.<span style="color: black;">/</span>.$appName.<span style="color: black;">/</span>.$streamName.<span style="color: black;">.flv?auth_key=</span>.$timeStamp.<span style="color: black;">-0-0-</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">.$flv_md5hash;</p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$hls_sstring&nbsp;=&nbsp;<span style="color: black;">/</span>.$appName.<span style="color: black;">/</span>.$streamName.<span style="color: black;">.m3u8-</span>.$timeStamp.<span style="color: black;">-0-0-</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">.$play_key;</p>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$hls_md5hash&nbsp;=&nbsp;md5($hls_sstring);</p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$hls_play_url&nbsp;=&nbsp;<span style="color: black;">http://</span>.$play_domain.<span style="color: black;">/</span>.$appName.<span style="color: black;">/</span>.$streamName.<span style="color: black;">.m3u8?auth_key=</span>.$timeStamp.<span style="color: black;">-0-0-</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">.$hls_md5hash;</p>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: black;">echo</span>&nbsp;<span style="color: black;">rtmp播放<span style="color: black;">位置</span>:&nbsp;</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">.$rtmp_play_url;</p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: black;">echo</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;PHP_EOL;</p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: black;">echo</span>&nbsp;<span style="color: black;">flv播放<span style="color: black;">位置</span>:&nbsp;</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">.$flv_play_url;</p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: black;">echo</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;PHP_EOL;</p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: black;">echo</span>&nbsp;<span style="color: black;">hls播放<span style="color: black;">位置</span>:&nbsp;</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">.$hls_play_url;</p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: black;">echo</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;PHP_EOL;</p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: black;">return</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">;</p>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">}</p><span style="color: black;">//推流域名</span>$push_domain&nbsp;=<span style="color: black;">testpush.cn</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">;</p><span style="color: black;">//推流域名配置的鉴权Key</span>$push_key&nbsp;=&nbsp;<span style="color: black;">test_Push_key</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">;</p><span style="color: black;">//生成随机的AppName</span>$appName&nbsp;=&nbsp;md5(uniqid(microtime(<span style="color: black;">true</span>),<span style="color: black;">true</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">));</p><span style="color: black;">//生成随机的StreamNmae</span>$streamName&nbsp;=&nbsp;md5(uniqid(microtime(<span style="color: black;">true</span>),<span style="color: black;">true</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">));</p><span style="color: black;">//配置过期时间为1小时</span>$expireTime&nbsp;=&nbsp;<span style="color: black;">3600</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">;</p><span style="color: black;">//播放域名</span>$play_domain&nbsp;=&nbsp;<span style="color: black;">testPlay.cn</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">;</p><span style="color: black;">//播放域名配置的鉴权Key</span>$play_key&nbsp;=&nbsp;<span style="color: black;">test_play_key</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">;</p>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">push_url($push_domain,$push_key,$expireTime,$appName,$streamName);</p>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">play_url($play_domain,$play_key,$expireTime,$appName,$streamName);</p><span style="color: black;">?&gt;</span>
    </span><img src="https://mmbiz.qpic.cn/mmbiz_gif/X36HLl2EicOfbCTTtzwpbdicOhvibmKu9O9jGSLPicT5IVjk2U8YETibumKAAa5K55Y3mdvGOvhjfbUGdEibKx8E5BJQ/640?wx_fmt=gif&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1" style="width: 50%; margin-bottom: 20px;"><span style="color: black;"><strong style="color: blue;"><span style="color: black;">原文链接:https://www.cnblogs.com/jiqing9006/p/6599492.html</span></strong></span><span style="color: black;"><span style="color: black;">以上<span style="color: black;">便是</span>本篇分钟的<span style="color: black;">所有</span>内容,</span><span style="color: black;"><strong style="color: blue;"><span style="color: black;"><span style="color: black;">期盼</span>各位程序员们<span style="color: black;">奋斗</span><span style="color: black;">提高</span>个人技术。</span></strong></span><span style="color: black;">最后,<span style="color: black;">博主</span>温馨提示:<span style="color: black;">每日</span>阅读5分钟,<span style="color: black;">每日</span>学习一点点,<span style="color: black;">每日</span>进步一点点。</span></span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="https://mmbiz.qpic.cn/mmbiz_gif/X36HLl2EicOfSLeDjYdhheic53iaMxy6jzuQaBEXzfu12r8KsocY8g1D5GGfcUJ4nibr37JY3ZZBu1wjKiaNxEASXUA/640?wx_fmt=gif&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1" style="width: 50%; margin-bottom: 20px;"></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">丨热门教程资源免费领丨</span></strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="https://mmbiz.qpic.cn/mmbiz_png/QibLP1rpwH8u6As0pkzHcbDO9VThW7ug7KH1LUeUYxVVUjBmE0QPE0kiaQ9sibJOsO7LFZUjDfGLymuTDia6ECUfCQ/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" style="width: 50%; margin-bottom: 20px;"></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="https://mmbiz.qpic.cn/mmbiz_png/QibLP1rpwH8u6As0pkzHcbDO9VThW7ug71xiad2JPKorMfGSgI5KM8x6YrP9IKEHO7NCbicVPmu7PnoVrZ8XO4K6g/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" style="width: 50%; margin-bottom: 20px;"></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="data:image/svg+xml,%3C%3Fxml version=1.0 encoding=UTF-8%3F%3E%3Csvg width=1px height=1px viewBox=0 0 1 1 version=1.1 xmlns=http://www.w3.org/2000/svg xmlns:xlink=http://www.w3.org/1999/xlink%3E%3Ctitle%3E%3C/title%3E%3Cg stroke=none stroke-width=1 fill=none fill-rule=evenodd fill-opacity=0%3E%3Cg transform=translate(-249.000000, -126.000000) fill=%23FFFFFF%3E%3Crect x=249 y=126 width=1 height=1%3E%3C/rect%3E%3C/g%3E%3C/g%3E%3C/svg%3E" style="width: 50%; margin-bottom: 20px;"></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">上下滑动查看<span style="color: black;">更加多</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">(</span><span style="color: black;">在下方公众号<span style="color: black;">回复「<strong style="color: blue;">资料</strong>」</span>,<span style="color: black;">就可</span>领取哦</span><span style="color: black;">)</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">↓↓↓</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">点个赞</span></strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="https://mmbiz.qpic.cn/mmbiz_gif/Ljib4So7yuWge7Mibiad1tV0iaF8zSD5gzicbYiaOtl6tmz4onkADe25mdeWcVhZlQ8Q0bH73nZAwICyJ4pPgJU3VrCg/640?wx_fmt=gif&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1" style="width: 50%; margin-bottom: 20px;"></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">再走吧</span></strong></p>




4lqedz 发表于 2024-10-23 09:44:55

感谢你的精彩评论,带给我新的思考角度。

m5k1umn 发表于 2024-10-29 10:00:35

百度seo优化论坛 http://www.fok120.com/
页: [1]
查看完整版本: [精选] php亦是能够做直播相关业务研发的