nginx 搭建http协议拖动播放 FLV 视频播放服务器

原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 、作者信息和本声明。否则将追究法律责任。http://deidara.blog.51cto.com/400447/235562
所需要的 播放器,我用的开源的 JW FLV Media Player 我把我的上传到了blog 大家可以下载。。
做了一点点改动!!
 
shell $> wget 'http://downloads.sourceforge.net/project/yamdi/yamdi/1.4/yamdi-1.4.tar.gz?use_mirror=nchc'
shell $> wget 'http://sysoev.ru/nginx/nginx-0.7.64.tar.gz'
 
shell $> tar zxvf nginx-0.7.64.tar.gz
shell $> cd nginx-0.7.64
shell $> groupadd www
shell $> useradd -g www www
shell $> ./configure --prefix=/usr/local/nginx --user=www --group=www --with-http_flv_module --with-http_gzip_static_module --with-http_stub_status_module --with-cc=gcc --with-cc-opt=" -O3"
shell $> make
shell $> make installl
 
shell $> tar zxvf yamdi-1.4.tar.gz
shell $> cd yamdi-1.4
shell $> gcc yamdi.c -o yamdi -O3 -Wall
shell $> mv yamdi /usr/bin/
 
注意我们编译的 yamdi 它起着重要的作用,因为一个FLV视频要能够拖拽播放,这个FLV在其 metadata中有关键桢的信息,但大部分FLV 是没有的。所以,我们要甬道开源的yamdi来为视频添加关键帧信息
命令为 
shell $> yamdi -i input.flv -o out.flv
 
shell $> cd /usr/local/nginx/conf
shell $> cat nginx.conf
user  www;
worker_processes  1;
 
error_log  logs/error.log;
 
pid        logs/nginx.pid;
events {
    worker_connections  1024;
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
    server {
        listen       80;
        server_name  localhost;
        root    /var/www;
        index   index.html;
 
        charset utf-8;
###   重要部分 
        location ~ \.flv {
            flv;
        }
 
 
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
 
 shell $> mkdir -p /var/www 
 shell $> cd /var/www
 shell $> cat index.html
<html>
<script type="text/JavaScript" src=\'#\'" /script>
<head>
<script type="text/JavaScript">
 
 
/* <![CDATA[ */
function createPlayer() {
 
var flashvars = {
 
file:"video.flv",
 
type:"http",
 
image:"preview.jpg",
 
autostart:"false",
 
streamer:"start"
 
}
 
var params = {
 
allowfullscreen:"true",
 
allowscriptaccess:"always"
 
}
 
var attributes = {
 
id:"player1",
 
name:"player1"
 
}
swfobject.embedSWF("player.swf", "placeholder1", "320", "196", "9.0.115", false, flashvars, params, attributes);
 
}
/* ]]> */
</script>
</head>
<body onload="createPlayer();">
 
<div id="placeholder1"></div>
</body>
</html>
 
####重要部分`就是黄色字体部分,
#### type参数为 "http",是表明了http方式播放、访问
#### streamer 参数为 “start,这个参数用于传递给服务器从特定的关键开始播放,nginx编译了 flv 模块 所以是支持的。。
 
好了现在就 打开 IE 来测试吧``为了能更好的测试,你可以利用 nginx 限速功能,这样明显,或者你用一个比较大的FLV 来做测试,记得要用 yamdi 添加一下关键侦哦~
 
 
ps:现在我们的任务就是,用户上传各种格式的媒体文件,转换成FLV格式,然后在由yamdi 添加播放关键侦~~目前就是这样得了~~
 
媒体转换文章请看我写的另一篇文章:
ffmpeg支持常用的所有格式转换FLV
 
参考:
 

本文出自 “linuxer” 博客,请务必保留此出处http://deidara.blog.51cto.com/400447/235562

原文地址:https://www.cnblogs.com/chenhaib/p/2827965.html