Apache 流媒体 拖动模块编译
http://www.server110.com/apache/201403/6943.html
apache下配置flv拖动
环境:debian apache2 ckplayer
1、安装apxs工具。
apxs 是Apache的扩展工具,用于编译一个或多个源程序或目标代码文件为动态共享对象,使之可以用LoadModule指令在运行时加载到Apache 服器中。
作为apache模块的编译工具,用它来编译mod_flvx.c文件。
debian和ubuntu下,apxs被放在apache2-threaded-dev和apache2-prefork-dev里,安装任一个即可。
apt-get install apache2-prefork-dev
whereis apxs2 查看安装路径
man apxs 如果你想看看这东西怎么用的话
2、下载mod_flvx.c并进行编译
wget https://github.com/osantana/mod_flvx/blob/master/mod_flvx.c 或者
wget http://people.apache.org/~pquerna/modules/mod_flvx.c
使用apxs进行编译,编译前,请检查apxs的版本,如果新安装的基本没啥问题吧
apxs -c -i -a ./mod_flvx.c
3、在apache的配置文件中增加mod_flvx.so模块,并添加对.flv的处理
在apache的conf.d目录下创建mod_flvx.conf文件,并写入以下内容
LoadModule flvx_module /usr/lib/apache2/modules/mod_flvx.so
AddHandler flv-stream .flv
4、重启apache
5、如果还不能拖动,则
1)FLV没有metadata关键帧数据
可以使用yamdi或flvtool2为你的flv视频添加关键帧
yamdi -i source.flv -o dest.flv或
flvtool2 -U source.flv
如果没有yamdi或者flvtool2可apt-get先安装。
这里我用flvtool2报错,于是用了yamdi,没报错。据说yamdi效率更高。
2)如果还不能拖动,则尝试配置播放器。
我这里用的是ckplayer。
搜了一下ckplayer的配置:http://www.ckplayer.com/view.php?id=82
ckplayer.js里
(1)ck.setup = '1,1,1,1,1,1,0,0,1,2,5';的第6个参数,是否使用http流式控制1是/0不是
(2)h的值,h:'1',//播放http视频流时采用何种拖动方法,0是按关键帧,1是按关键时间点
(3)q:'',//视频流拖动时参考函数,默认是start。
关于选择关键帧还是关键时间点的区别,默认的是flv是按关键时间点,而mp4是按关键帧来随意拖动的,但很多网站是把这二个设置成统一的,要么都按关键帧,要么都按关键时间点。
这里我执行了(1)。
然后,就好了。。。可以拖动了。。。
转载请注明原文地址:http://www.server110.com/apache/201403/6943.html
mp4-----------
http://h264.code-shop.com/trac/wiki/Mod-H264-Streaming-Apache-Version2
Dependencies¶
We will be using apxs2, the APache eXtenSion tool, to build and install the module for the Apache server.
Make sure you have apxs2 installed:
sudo apt-get install apache2-threaded-dev
Download
Download the source of the H264 Streaming Module for Apache.
cd ~
wget http://h264.code-shop.com/download/apache_mod_h264_streaming-2.2.7.tar.gz
tar -zxvf apache_mod_h264_streaming-2.2.7.tar.gz
Build
cd ~/mod_h264_streaming-2.2.7
./configure --with-apxs=`which apxs2`
make
sudo make install
Configuration
Edit the configuration file (in /etc/apache/httpd.conf) so that file requests ending in ".mp4" are handled by the h264_streaming_module.
LoadModule h264_streaming_module /usr/lib/apache2/modules/mod_h264_streaming.so
AddHandler h264-streaming.extensions .mp4
Start Apache.
sudo /etc/init.d/apache start
Build & Configuration (CentOS 5.2)
CentOS users can follow these intructions for building the module instead. It uses apxs (instead of apxs2) and httpd (instead of apache).
sudo yum install httpd-devel
sudo yum install httpd mod_ssl cd ~/mod_h264_streaming-2.2.5
./configure
make
sudo make install sudo vi /etc/httpd/conf/httpd.conf
Add the line
'AddHandler h264-streaming.extensions .mp4'
after the line
'LoadModule h264_streaming_module /usr/lib/httpd/modules/mod_h264_streaming.so'
sudo /etc/init.d/httpd start
License
This version is free if you agree to the noncommercial license. Please mention its use on your website, in the lines of 'This website uses H264 pseudo video streaming technology byCodeShop'.
Our commercial license is very inexpensive, see the following page to check if you need a commercial license.
Testing
Continue to the testing page to verify your setup.
Demo
See http://h264-demo.code-shop.com/demo/apache/testlist.html for a demo running Apache.
Apache Module 开发后记
开发出 apache 2.0 的模块以后,又面对着要将其移植到 apache 其他版本的需求,经过这段时间一点点的修补,现在我的模块已经可以同时在 1.3/2.0/2.2 下编译。甚至在 2.0/Win32 环境下也编译出了 dll,供在个人PC上做开发的同事使用。
我感觉如果项目不复杂的话,可以学习我这样把所有的内容放在一个文件里面的做法。
最重要的就是利用 MODULE_MAGIC_COOKIE 的定义,把 1.3 和 2.0/2.2 的不同之处融合在一起。例子:
#if MODULE_MAGIC_COOKIE == 0x41503230UL || MODULE_MAGIC_COOKIE == 0x41503232UL
#include "util_filter.h"
#include "apr_strings.h"
module AP_MODULE_DECLARE_DATA foobar_module;
#define APLOG_FOOBAR APLOG_ERR,0
#else
module MODULE_VAR_EXPORT foobar_module;
#define apr_pool_t pool
#define apr_table_t table
#define apr_pcalloc ap_pcalloc
#define apr_table_unset ap_table_unset
#define apr_table_set ap_table_set
#define apr_table_get ap_table_get
#define apr_table_make ap_make_table
#define apr_pstrdup ap_pstrdup
#define apr_snprintf ap_snprintf
#define apr_pstrndup ap_pstrndup
#define APLOG_FOOBAR APLOG_ERR
#endif /* MODULE_MAGIC_COOKIE == 0x41503230UL */
同样,模块初始化的部分也这样针对不同版本定义一下。
这样主要的功能函数就可以使用同样的代码模块,并使用 apr_* 系列函数族了。
之所以要对 APLOG_ERR 做定义,是因为在 1.3 和 2.x 版本中,ap_log_error 和 ap_log_rerror 所使用的参数数目不一致,2.x 的参数要多一个,因此针对 2.x自动增加一个参数——",0"
2.0 和 2.2 有些地方也有小差别,我的代码里面就碰到了 apr_socket_create 的参数不一样。同样简单 #if 就可以处理了。
在 1.3 里面 module initializer 如果 2.x 里面的 post_config 会运行两次,而且2.x 上的这个小技巧无法直接使用了。本来是不影响程序运行的,但还是想出了一个变态的办法来解决它。module initializer 两次执行之间的一个重要事件就是 apache 的 daemonize。那样怎么来判断当前进程是否在 daemon 状态下呢?我的方案是:
/* 小技巧,用于帮助 init_module 只执行一次检查 */
#define MAX_FDS 1024
int daemon_flag(int fds[MAX_FDS])
{
int fd;
int newfd;
int i;
int opt;
socklen_t optlen = sizeof(int);
int ret = 0;
memset(fds, 0, sizeof(int) * MAX_FDS);
newfd = fd = socket(AF_INET,SOCK_STREAM,0);
while (newfd < MAX_FDS && newfd > 0) {
fds[newfd] = 1;
newfd = dup(fd);
}
for (i = 0; i < MAX_FDS; i++) {
if (fds[i] == 1) {
close(i);
} else {
if (0 == getsockopt(i, SOL_SOCKET, SO_REUSEADDR, &opt, &optlen)) {
fds[i] = -1; //这样返回以后也知道哪些 fd 被监听
ret = 1;
}
}
}
return ret;
}
因为我知道 apache 必然会对监听套接字设置 SO_REUSEADDR,所以可如此判断。
由于 apache2 有了 apr 的支持,几乎不用修改任何代码模块就可以在 win32 下编译。而且只需要 MS 的免费工具就可以了,包括 MSVC C++ Toolkit 2003 和 Platform SDK。设置好 INCLUDE/LIB 路径后,只需要执行
cl /MD /D "WIN32" /c mod_foobar.c
link /DLL mod_foobar.obj libhttpd.lib libapr.lib
这样就得到了可被 LoadModule 的 mod_foobar.dll
win32 下我碰到的问题稍微麻烦一些。启动 apache 无法成功,报告什么 OPENSSL_Applink 错误。看了 openssl 的 FAQ,说什么要 include 一个 applink.c,但仍然无济于事。不过查看 applink.c 后发现,它似乎和 IO 库相关;最后我把以前使用的 stdio 替换成了 openssl 自己的 bio 函数族,该问题就消失了。
openssl 的 win32 库从这里下载并安装
Apache 流媒体 拖动模块编译的更多相关文章
- centos 6.4 Apache 配置 flv mp4.h264 流媒体拖动
http://blog.csdn.net/xst686/article/details/9763995 加入流媒体扩展后要重启 httpd flv 流媒体 <textarea style=&qu ...
- 给已经编译运行的Apache增加mod_proxy模块的配置方法
在Linux系统下,需要给已经编译运行的Apache增加mod_proxy模块,可以按照如下方法配置. 具体配置步骤如下: 1. 首先定位到Apache源码的 proxy目录 # cd /root/s ...
- 为Apache动态增加模块
Apache已经安装完毕并投入运行,但是后来却发现部分模块没有加载,当然有两个方法: 1. 一是完全重新编译Apache, 再安装 2. 编译模块为SO文件,使用LoadModule指令加载扩展模块. ...
- Nginx SPDY Pagespeed模块编译——加速网站载入
在看<Web性能权威指南>的时候,看到了SPDY这货,于是便开始折腾起了这个了,也顺便把pagespeed加了进去. Nginx SPDY 引自百科~~ SPDY(读作“SPeeDY”)是 ...
- apache动态添加模块
Apache已经安装完毕并投入运行,但是后来却发现部分模块没有加载,当然有两个方法: 1. 一是完全重新编译Apache, 再安装 2. 编译模块为SO文件,使用LoadModule指令加载扩展模块. ...
- Apache 的mod_auth_cas模块的介绍和使用
apache的mod_auth_cas模块是一个集成到apache中的cas客户端,一般是配合Apache的反向代理来使用,对某个url的请求先经过apache,apache会判断是否经过cas认证, ...
- SNMP 原理及配置简述 net-snmp-utils net-snmp 第2版基于SNMP 群体名(community name) 第3版引入了安全性更高的访问控制方法 SNMP协议操作只有4种 Apache的php_snmp 模块
SNMP 原理及配置简述 net-snmp-utils net-snmp 第2版基于SNMP 群体名(community name) 第3版引入了安全性更高的访问控制方法 SNMP协议操作只有4种 ...
- 使用Apache TVM将机器学习编译为WASM和WebGPU
使用Apache TVM将机器学习编译为WASM和WebGPU TLDR 在Apache TVM深度学习编译器中引入了对WASM和WebGPU的支持.实验表明,在将模型部署到Web时,TVM的WebG ...
- Android之源码之模块编译和调试
Android之源码之模块编译调试 (一) 进行源码模块修改进行编译的调试 1.首先是从git或者svn上拉一套完整的工程下来,然后全编一下,一般这个时间比较长,大概会得2,3个小时左右, 2,编译成 ...
随机推荐
- Scott Hanselman's 2014 Ultimate Developer and Power Users Tool List for Windows -摘自网络
Everyone collects utilities, and most folks have a list of a few that they feel are indispensable. ...
- 转载 GUID介绍
转载 http://www.cnblogs.com/illele/archive/2008/02/25/1080554.html GUID(Global unique identifier)全局唯一标 ...
- (10.09作业)学生选课数据库SQL语句练习题
- ECSHOP在线手册之布局参考图-首页 index.dwt
A.logo替换 1,设置方法 后台商店设置里,上传logo就行,注意logo的名称必须是logo.gif 2,代码相关 page_header.lbi 中 <a href=" ...
- BZOJ 2298: [HAOI2011]problem a 动态规划
2298: [HAOI2011]problem a Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://www.lydsy.com/JudgeOnli ...
- 设计模式-工厂方法(Demo)
工厂方法 工厂方法跟简单工厂一样.都是创建型的设计模式.他攻克了简单工厂的违背开放封闭的缺点. 故事 主人--人家做饭好累的.女仆抱着我大腿说着.自从上次把她买进家.没做了几次饭就喊累--看着她那出处 ...
- 基于反射实现自己主动化restful开发
[Author]: kwu 基于反射实现自己主动化restful开发,通用的仅仅须要写查询数据库的sql.并增加相应的javabean实现的高速restful服务的开发. 1.编写数据库的查询sql. ...
- VS2005工程迁移到Eclipse CDT
原工程在VS2005下创建,后迁移到Eclipse CDT 3.3.2 + MingGW下,并增加makefile文件. 原VS2005下工程Sample,实现了对类SampleClass封装,生成S ...
- mysql中不同事务隔离级别下数据的显示效果--转载
事务是一组原子性的SQL查询语句,也可以被看做一个工作单元.如果数据库引擎能够成功地对数据库应用所有的查询语句,它就会执行所有查询,如果任何一条查询语句因为崩溃或其他原因而无法执行,那么所有的语句就都 ...
- ie7兼容性 绝对定位元素之间的遮盖问题
今天在调试ie7兼容性问题的时候,遇到了一个棘手的问题,解决了一天无果,晚上看到一位大神写的心得,最终解决. 网址:http://www.jb51.net/css/148606.html#commen ...