二蛋 发布的文章

使用ffmpeg进行ts切片并AES-128加密

目录应包含文件

input.mp4
videokey.info
video.key

videokey.info文件内容示例

http://example.com/video.key
video.key

video.key文件内容示例

DMvkBs7vNlok1kj9

切片并加密

ffmpeg -i input.mp4 -c copy -bsf:v h264_mp4toannexb -hls_time 5 -hls_list_size 0 -hls_key_info_file videokey.info output.m3u8

-hls_time 设置每片的时长,默认值为2。单位为秒
-hls_list_size 设置播放列表保存的最多条目,设置为0会保存所有切片信息,默认值为5

由于解密的key文件都是公开的,所以并不能算上完全加密,用户只要把你的key+m3u8里的ts切片文件全部下载,用ffmpeg还是能解,这时就要考虑url的key防止用户直接下载和盗链。

编译安装ffmpeg

1、安装yasm

#CentOS
yum install yasm
 
#Debian
apt-get install yasm

无效则

wget http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz
tar zxvf yasm-1.3.0.tar.gz
cd yasm-1.3.0
./configure
make && make install

2、安装ffmpeg

yum install git
git clone https://git.ffmpeg.org/ffmpeg.git ffmpeg
cd ffmpeg
./configure --enable-shared --prefix=/usr/local/ffmpeg
make && make install

查看ffmpeg版本

/usr/local/ffmpeg/bin/ffmpeg -version


如显示错误为

/usr/local/ffmpeg/bin/ffmpeg: error while loading shared libraries: libavdevice.so.56: cannot open shared object file: No such file or directory


修改/etc/ld.so.conf/ld.so.conf文件

vi /etc/ld.so.conf

内容修改如下,并保存

include ld.so.conf.d/*.conf
/usr/local/ffmpeg/lib/

保存好后,运行↓

ldconfig

添加到环境变量

vi /etc/profile

再最后一行添加

export PATH=/usr/local/ffmpeg/bin/:$PATH

保存退出并重启

查看ffmpeg版本

ffmpeg -version

SeaCMS默认只调用无星级推荐视频

编辑 /include/main.class.php 文件,在1323行找到:

if(!empty($vcommend)){
switch (trim($vcommend)) {
    case "all":
        $whereCommend=" and  m.v_commend>0";
    break;
    default:
        if(strpos($vcommend,',')>0) $whereCommend=" and m.v_commend in($vcommend)"; else $whereCommend=" and m.v_commend='$vcommend'";
}
}else{
        $whereCommend="";
}

修改为:

if(!empty($vcommend)){
switch (trim($vcommend)) {
    case "all":
        $whereCommend=" and  m.v_commend>0";
    break;
    default:
        if(strpos($vcommend,',')>0) $whereCommend=" and m.v_commend in($vcommend)"; else $whereCommend=" and m.v_commend='$vcommend'";
}
}else{
        $whereCommend=" and  m.v_commend=0";
}

这样以后,在单层循环标签中,要指定 commend=all 才可以调用所有视频:

{seacms:videolist num=8 order=time type=all commend=all start=5 letter=a lang=英语 area=美国 year=2018}

SeaCMS官方资源库采集的过滤

1、备注
编辑 /include/collection.class.php 文件,找到:

$v_data['v_note'] = (String)$video->note;//影片备注

在下方插入:

$v_data['v_note'] = str_replace(array('1024','高清','中字','国语','版','1280','中英双字','|','原声','粤语','英语','韩语','超清','无字'),'',$v_data['v_note']);

2、分集名称
编辑 /include/collection.class.php 文件,找到:

$v_data['v_playdata'] = substr($v_data['v_playdata'],0,-3);

在下方插入:

$v_data['v_playdata'] = str_replace(array('1024','1280','|','版'),'',$v_data['v_playdata']);

3、简介中的html标签
编辑 /include/collection.class.php 文件,找到:

$v_data['v_des'] = htmlspecialchars($video->des);

修改为:

$v_data['v_des'] = strip_tags($video->des,['br','span','b','font']);

其中 br span b font 为允许的标签

4、过滤(不采集)指定来源的数据
编辑 /include/collection.class.php 文件,找到:

if($video->dl->dd[$i]['flag']=='down')
{$v_data['v_downdata'] .= "下载地址1$$".$video->dl->dd[$i]."$$$";}

在下方插入:

if($video->dl->dd[$i]['flag']=='youku')
{$v_data['v_playdata'] .= "";}

Lazyload遇到tab选项卡 必须滚动屏幕才能显示图片的解决方法

可尝试将:

<script type="text/javascript">
  $(function() {
      $("img").lazyload();
  });
</script>

替换为:

<script type="text/javascript">
$("img").lazyload({
    skip_invisible : false,
     effect:"fadeIn"
});
</script>

也可替换为:

<script type="text/javascript">
 $(function() {          
     $("img").lazyload({
         event : "sporty"
     });
 });
 $(window).bind("load", function() {
     var timeout = setTimeout(function() { $("img").trigger("sporty") }, 5000);
 });
</script>

实际页面加载完成 5 秒后自动加载图片