02 开发页面、配置并启动播放

在完成视频的切割之后,我们就可以借助nginx来播放处理好的视频集合。

1、环境约束

  • nginx-1.14.0 windows版本

    2、操作步骤

  • 1 创建播放页面
    (1)在D盘下创建一个文件夹video/plugin,在该文件夹下拷贝video.js、videojs-contrib-hls.js以及video-js.css。
    (2)在D:/video文件夹下创建一个文件index.html,内容如下:
<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <title>视频播放</title>
    <link href="plugin/video-js.css" rel="stylesheet">
</head>
<body>
<video id=example-video width=800 height=600 class="video-js vjs-default-skin vjs-big-play-centered" controls>
    <source
            src="http://localhost/hls/wanho.m3u8"
            type="application/x-mpegURL">
</video>
<script src="plugin/video.js"></script>
<script src="plugin/videojs-contrib-hls.js"></script>
<script>
    var player = videojs('example-video');
    player.play();
</script>
</body>
</html>
  • 2 解压nginx压缩包,配置nginx.conf
    在http的server节点下加入以下内容
location /video {
    alias "D:/video/";
    index  index.html index.htm;
}
location /hls {
    alias "D:/ffmpeg-20190502-7eba264-win64-static/bin/hls/";
}
  • 3 启动nginx
    进入nginx文件夹的bin目录下,打开命令行,执行nginx.exe
  • 4 测试
    在浏览器中输入http://localhost/video/index.html,就能看到视频的播放。
    以上就是借助nginx访问第一小节分割的视频之过程。

猜你喜欢

转载自www.cnblogs.com/alichengxuyuan/p/12519931.html
今日推荐