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,编译成 ...
随机推荐
- 远程控制篇:在DELPHI程序中拨号上网
用MODEM拨号上网,仍是大多数个人网民选择上网的方式.如果能在我们的应用程序中启动拨号连接(如IE浏览器程序中的自动拨号功能),无疑将会方便我们的软件用户(不用再切换应用程序,运行拨号网络),提高我 ...
- mac linux netstat -n
一直都不明白为什么mac就是不现实8080端口,现在明白了 USERtekiiMac-3:~ user$ netstat -an | grep tcp46 tcp46 0 0 *.8009 *.* L ...
- 射频识别技术漫谈(6)——通讯协议概述【worldsing笔记】
通讯协议是通讯的双方或多方在交流时遵守的规矩,包括谁先发起通讯,先交流什么,后交流什么,一方如何问,另一方如何答等.在这里通迅的双方指的是读写器和卡片. 首先是谁先发起通讯,很显然有两种,读写器先发言 ...
- C++学习笔记(十四):模板
模板就是实现代码重用机制的一种工具,它可以实现类型参数化,即把类型定义为参数,从而实现了真正的代码可重用性.模版可以分为两类,一个是函数模版,另外一个是类模版.Java中对应的技术称为泛型. 函数模板 ...
- java图片处理
import java.awt.image.BufferedImage; import java.io.File; import java.io.FileOutputStream; import ja ...
- git 快速入门(二)
一.引子 git代码托管的优秀工具之一, 其工作原理和svn截然不同.一旦拥有主干master分支权限, 只要在本地拉取主干分支, 可以随时随地切换分支. 它拥有众多优点,eg :支持在断网的情况下, ...
- WinForm中如何判断关闭事件来源于用户点击右上角的“关闭”按钮
在C#的WinForm程序中,有的时候需要判定关闭请求从哪里发出来的.比如是用户点击了右上角的“关闭”按钮,还是调用了WinForm.Close()方法.最典型的是要知道点击右上角的“关闭”按钮发出的 ...
- UIView中触摸事件touchBegin
UIView触摸事件touchBegin 等一系列方法 1)手指按下 - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event; ...
- CentOS安装Nginx安装详解
一.准备工作,安装依赖包,缺一不可!(推荐先用命令查看自己是否已经安装一下软件,确认没有再安装) --------------------------------------------------- ...
- Android 获取手机SIM资料详解
TelephonyManager类主要提供了一系列用于访问与手机通讯相关的状态和信息的get方法.其中包括手机SIM的状态和信息.电信网络的状态及手机用户的信息.在应用程序中可以使用这些get方法获取 ...