Apache Streaming Media Drag module compilation

Source: Internet
Author: User

Http://www.server110.com/apache/201403/6943.html

Configure FLV drag under Apache

Environment: Debian Apache2 Ckplayer

1, install APXS tools.

APXS is an Apache extension tool that compiles one or more source programs or target code files into a dynamically shared object so that it can be loaded into the Apache server at run time with loadmodule directives.

As a compilation tool for the Apache module, use it to compile the mod_flvx.c file.

Under Debian and Ubuntu, APXS is placed in Apache2-threaded-dev and Apache2-prefork-dev, and any one can be installed.

Apt-get Install Apache2-prefork-dev

Whereis APXS2 Viewing the installation path

Man APXS If you want to see how this thing is going to work,

2. Download the MOD_FLVX.C and compile

Wget https://github.com/osantana/mod_flvx/blob/master/mod_flvx.c or

wget http://people.apache.org/~pquerna/modules/mod_flvx.c

Use APXS to compile, before compiling, please check the version of APXS, if the new installation of basic no problem.

Apxs-c-i-a./mod_flvx.c

3. Add the Mod_flvx.so module to the Apache configuration file, adding the processing of. flv

Create the mod_flvx.conf file in the Apache CONF.D directory and write the following:

LoadModule flvx_module/usr/lib/apache2/modules/mod_flvx.so

AddHandler flv-stream. flv

4. Restart Apache

5, if you cannot drag, then

1) FLV does not have metadata keyframe data

You can add keyframes to your FLV video using Yamdi or flvtool2

Yamdi-i Source.flv-o dest.flv or

Flvtool2-u source.flv

If there is no yamdi or flvtool2 can be apt-get installed first.

Here I use flvtool2 error, so use Yamdi, no error. Yamdi is said to be more efficient.

2) If you are not yet able to drag, try configuring the player.

I use the ckplayer here.

Search for it. Ckplayer Configuration: http://www.ckplayer.com/view.php?id=82

Ckplayer.js.

(1) ck.setup = ' 1,1,1,1,1,1,0,0,1,2,5 '; the 6th parameter, whether to use HTTP streaming control 1 Yes/0 not

(2) H value, h: ' 1 ',//when the HTTP video stream is played by which drag method, 0 is by key frame, 1 is by key point in time

(3) Q: ",///video stream Drag reference function, default is start."

The difference between choosing a keyframe or a key point in time, by default, is that the FLV is at a critical point in time, while MP4 is dragged at random by key frames, but many sites set these two as unified, either by keyframes or by key points in time.

Here I carried out (1).

Then, just fine ... You can drag the ...

Reprint please specify the original address: http://www.server110.com/apache/201403/6943.html

MP4-----------

Http://h264.code-shop.com/trac/wiki/Mod-H264-Streaming-Apache-Version2

Dependencies¶

We'll be using a 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.GZTAR-ZXVF apache_mod_h264_ Streaming-2.2.7.tar.gz
Build
CD ~/mod_h264_streaming-2.2.7./configure--with-apxs= ' which apxs2 ' Makesudo make install
Configuration

Edit the configuration file (in/etc/apache/httpd.conf) So, file requests ending in ". mp4" is handled by the H264_STR Eaming_module.

LoadModule H264_streaming_module/usr/lib/apache2/modules/mod_h264_streaming.soaddhandler 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).

License

This version was free if you agree to the noncommercial license. Please mention it use on your website, in the lines of ' This website uses H264 pseudo video streaming technology by? C Odeshop'.

Our commercial license are 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 Development PostScriptsubmitted by Qyb on Tuesday, 2007-02-13 12:14

Continuation of a previous article

After the development of the Apache 2.0 module, and faced with the need to transplant it to other versions of Apache, after a little bit of patching, now my module can be compiled at the same time under 1.3/2.0/2.2. DLLs are compiled even in 2.0/win32 environments for colleagues who develop on personal PCs.

I feel that if the project is not complicated, I can learn how to put all the content in a file.

The most important thing is to use the definition of Module_magic_cookie to combine the differences between the 1.3 and the 2.0/2.2. Example:

#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 * *

Similarly, the part of the module initialization is defined for different versions.

So the main function function can use the same code module, and use the Apr_* series function family.

Aplog_err is defined because in versions 1.3 and 2.x, the number of parameters used by Ap_log_error and Ap_log_rerror is inconsistent, and 2.x parameters are one more, so a parameter is automatically added for 2.x-", 0"

2.0 and 2.2 There are small differences in some places, and my code has encountered apr_socket_create parameters. The same simple #if can be handled.

In 1.3 The module initializer if the 2.x inside of the Post_config will run two times, and 2.x on this little trick can not be used directly. It would not have affected the program to run, but still came up with a perverted way to solve it. One of the important events between module initializer two executions is Apache's daemonize. How can you tell if the current process is in the daemon state? My plan is to:

/* Tips to help init_module only perform one check */#define MAX_FDS 1024int 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_so Cket, SO_REUSEADDR, &opt, &optlen)) {                Fds[i] =-1;//This return also knows which FD is being monitored by                ret = 1;}        }}    return ret;}

Because I know that Apache is bound to set SO_REUSEADDR on the listening socket, so I can judge that.

Since Apache2 has APR support, it is possible to compile under Win32 without modifying any of the code modules. And it only requires MS free tools, including MSVC C + + Toolkit 2003 and Platform SDK. Once you have set the Include/lib path, you only need to perform
CL/MD/D "WIN32"/C MOD_FOOBAR.C
Link/dll mod_foobar.obj Libhttpd.lib Libapr.lib

So we get the mod_foobar.dll that can be LoadModule.

Win32 I have a little trouble with the problem. Boot Apache failed to report any openssl_applink errors. See the FAQ of OpenSSL, say what to include a applink.c, but still useless. However, after viewing applink.c, it seems to be related to the IO library; Finally, I replaced the previously used stdio with OpenSSL's own bio function family, and the problem disappeared.

The Win32 Library of OpenSSL is downloaded and installed from here

Http://httpd.apache.org/docs/current/platform/windows.html#down

Apache Streaming Media Drag module compilation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.