Skip to content

播放器插件、OSS存储、支付宝即时到账、Redis缓存、PHPmailer批量发送、Monolog 日志、ECharts 图表、PDO预处理、PHP-FFmpeg、WebSocket、RBAC、AngularJS

Notifications You must be signed in to change notification settings

TokenUndefined/php-project-practice

 
 

Repository files navigation

Tinywan GitHub stars image
image

Work experience based on ThinkPhp framework

    主要有视频播放器插件、阿里云OSS存储、支付宝即时到账接口、Redis缓存、PHPmailer批量发送邮件、Monolog 日志工具、ECharts图表库、PDO预处理、PHP-FFmpeg、WebSocket、无限级分类、RBAC、AngularJS等等


image

流媒体、视频编码、直播流测试库

  • 2016杭州·云栖大会集锦
    • https://vodcdn.alicdn.com/oss/taobao-ugc/1dde6e764244406cbe5962b26eee078c/1476754829/video.mp4
  • 阿里巴巴王坚完整版视频
    • https://vodcdn.alicdn.com/oss/taobao-ugc/e6fb60eae8594f9e812233489bfa2732/1476578718/video.mp4
  • RTMP协议直播源 
    • 亚太第一卫视(RTMP流) rtmp://v1.one-tv.com/live/mpegts.stream
    • 香港电视台直播 rtmp://live.hkstv.hk.lxdns.com/live/hks
    • 亚太卫视 rtmp://58.61.150.198/live/Livestream
    • 香港卫视公开的拉流地址 rtmp://live.hkstv.hk.lxdns.com/live/hks
    • 香港卫视公开的推流地址 rtmp://live.hkstv.hk.lxdns.com/live/tinywan123456
    • 香港卫视公开的推流测试地址 rtmp://live.hkstv.hk.lxdns.com/live/tinywan123456
  • RTSP协议直播源 
    • rtsp://184.72.239.149/vod/mp4://BigBuckBunny_175k.mov
  • HTTP协议直播源 
    • 香港卫视 http://live.hkstv.hk.lxdns.com/live/hks/playlist.m3u8
    • CCTV1高清 http://ivi.bupt.edu.cn/hls/cctv1hd.m3u8
    • CCTV5高清 http://ivi.bupt.edu.cn/hls/cctv5hd.m3u8
    • 杭康 http://live.hkstv.hk.lxdns.com/live/hks/playlist.m3u8

FFmpeg录制、转换以及流化音视频的解决方案

  • 更多FFmpeg 命令相关文档

  • 将网络直播源(RTMP流)拉取到内网(本地文件),切片成m3u8+ts

    • ffmpeg -i rtmp://live.hkstv.hk.lxdns.com/live/hks -f hls -hls_list_size 5 -hls_time 10 -hls_wrap 10 ./live.m3u8
  • FFmpeg 自动截取直播图片

    • ffmpeg -i rtmp://live.hkstv.hk.lxdns.com/live/hks -vframes 1 -y -f image2 -t 1 -s 600x480 $path/autoCli.jpg
  • FFmpeg的转码延时测试与设置优化,ffmpeg设置转码延时的参数和步骤如下:

    关闭sync-lookahead
    降低rc-lookahead,但别小于10,默认是-1
    降低threads(比如从12降到6)
    禁用rc-lookahead
    禁用b-frames
    缩小GOP,
    开启x264的 -preset fast/faster/verfast/superfast/ultrafast参数
    使用-tune zerolatency 参数

    • 测试案例(延时大概在0.2 -- 0.6 秒):
    • ./ffmpeg -i rtmp://192.168.1.12/live/src -tune zerolatency -vcodec libx264 -preset ultrafast -b:v 400k -s 720x576 -r 25 -acodec libfaac -b:a 64k -f flv rtmp://192.168.1.12/live/dst
  • 将本地摄像头RTSP流拉取到公网RTMP流(默认使用UDP协议传送)

    • ffmpeg -i rtsp://192.168.18.240:554/onvif/live/1 -c:a copy -c:v libx264 -f flv "rtmp://公网IP地址/live/tinywan123"
  • 将本地摄像头RTSP流拉取到公网RTMP流(TCP协议传送)

    • ffmpeg -rtsp_transport tcp -i rtsp://admin:12345@192.168.18.252:554/h264/ch1/main/av_stream -c:a copy -c:v libx264 -f flv rtmp://公网IP地址/live/tinywan123
  • 将rtmp流,以文件的形势保存到本地

    • ffmpeg -i "rtmp://tinywan.www.com/live123/4008899 live=1" -acodec copy -vcodec copy -f flv -y F:\Tinywan\Video\RTMPtest2test.flv
  • 列出本机的设备

    • ffmpeg -list_devices true -f dshow -i dummy
  • FFmpeg进行笔记本摄像头+麦克风实现流媒体直播服务

    • ffmpeg -f dshow -i video="Lenovo EasyCamera":audio="麦克风 (Realtek High Definition Audio)" -vcodec libx264 -acodec copy -preset:v ultrafast -tune:v zerolatency -f flv "rtmp://aitech.com/live/tinywan123"
  • 将本地摄像头RTSP流拉取到公网EasyDarwin流媒体服务器,播放RTSP流(TCP协议传送)

    • 推流模式:ffmpeg -i "rtsp://192.168.18.240:554/onvif/live/1" -vcodec copy -acodec copy -rtsp_transport tcp -f rtsp "rtsp://114.55.107.180:10554/tinywan123.sdp"
    • 播放地址:rtsp://114.55.107.180:10554/tinywan123.sdp

公共脚本库

  • Bootstrap/css http://libs.baidu.com/bootstrap/3.0.3/css/bootstrap.min.css
  • Bootstrap/js http://libs.baidu.com/bootstrap/3.0.3/js/bootstrap.min.js
  • Jquery http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js
  • Angular http://cdn.static.runoob.com/libs/angular.js/1.4.6/angular.min.js

最新的以ThinkPHP为WEB应用开发提供功能

jwplayer 播放器ajax同步获取播放地址

var default_stream_address;
function testPlay(name) {
    var url = 'http/127.0.0.1/getplay_rtmp_address';
    var data = {
        'name' : name
    };
    var success = function(response){
        default_stream_address = response;
        console.log(default_stream_address);
    };
    $.ajax({
        url:url,
        type:'get',
        data:data,
        dataType:'json',
        async:false,
        success:success
    });
    $("#testPlayModal").modal("show");
    console.log(111111111111111)
    console.log(default_stream_address)
    console.log(2222222222222222222)
    jwplayer("my-video").setup({
        file: default_stream_address,
        image: "/res/streaming/img/amai-logo-01.jpg",
        width: "100%",//580
        height: "370",//370
        hlshtml: true,
        autostart: true //自动播放
    });
}

常用单利模式调用

  • Redis单利模式:RedisInstance::Instance
  • PDO单利模式:PDOInstance::Instance
  • OSS单利模式:OssInstance::Instance
  • MonoLog单利模式:MonoLogInstance::Instance

支付功能

  • 支付宝支付
    • 即时到帐
    • 手机网站
    • 移动支付
    • 订单查询
    • 退款
    • 转款
  • 微信支付
    • APP支付
    • 公众号支付
    • 扫码支付

视频播放插件

播放器 代码路径 RTMP延迟 HLS延迟 FLV延迟 描述
Sewise HTML5/SewiseController/Index 20s 30s 20s ~
JPlayer HTML5/JPlayerController/Index 15s 30s 20s ~
Jwplayer HTML5/JwplayerController/Index 15s 30s 20s ~
SwfObject HTML5/SwfObjectController/Index 1~2S 30s 20s 推荐
Video HTML5/VideoController/Index 15s 30s 20s ~
VideoJS HTML5/VideoJSController/Index 3~5S 30s 20s 推荐

Google

doodle

VideoJs插件播放一个RTMP视频流

 <link href="__PUBLIC__/lib/video-js/video-js.css" rel="stylesheet">
 <script src="__PUBLIC__/lib/video-js/video.js"></script>
 <script>
     videojs.options.flash.swf = "__PUBLIC__/lib/video-js/video-js.swf"
 </script>
 <video 
    id="livestream" 
    class="video-js vjs-default-skin vjs-big-play-centered"
    controls autoplay preload="auto" width="1280" height="720"
    data-setup='{"example_option":true}'>
    <source src="rtmp://live.hkstv.hk.lxdns.com/live/hks" type="rtmp/mp4"></source>
 </video>

常用Shell脚本

  •  凌晨备份昨天的日志,放在该日期的月份目录下面,同时以昨天的时间为后缀名
    Shell文件夹/Logs文件夹/auto_backup_logs_del_current.sh
  •  RTMP模块的分发服务器分发本地流到各个节点服务器上去
    Shell文件夹/Logs文件夹/auto_backup_logs_del_current.sh
  •  每隔10分钟把每个活动对应的评论和礼物数量同步到MySQL数据库中去
    Shell文件夹/Redis文件夹/comment_redis_pdo.sh
  •  每隔10分钟把每个活动对应的评论和礼物数量同步到MySQL数据库中去
    Shell文件夹/Redis文件夹/comment_redis_pdo.sh
  •  Nginx RTMP录像自动上传到阿里云oss存储
    Shell文件夹/Rtmp文件夹/rtmpRecordedNotify.sh

What is he thinking about?

Tinywan

Git工作流指南:Gitflow工作流

Tinywan

About

播放器插件、OSS存储、支付宝即时到账、Redis缓存、PHPmailer批量发送、Monolog 日志、ECharts 图表、PDO预处理、PHP-FFmpeg、WebSocket、RBAC、AngularJS

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 36.2%
  • JavaScript 33.5%
  • CSS 17.8%
  • HTML 11.9%
  • Shell 0.4%
  • Smarty 0.2%