Using Nginx to stream h.264 video

Hi,

I’m currently trying to setup Nginx to stream an mp4 video file.

Currently I have read through:

http://h264.code-shop.com/trac/wiki/Mod-H264-Streaming-Nginx-Version2

http://h264.code-shop.com/trac/wiki/Mod-H264-Streaming-Testing-Version2

but wasn’t quite sure how to integrate these with Nginx itself.

I have a few questions regarding this:

Is this the mp4 module that I need to be able to stream or is there an
embedded solution?

Currently I’m running CentOS 6.2 as the server OS and have install Nginx
from the EPEL repo… does this contain the module or do I need to get
the source code and compile it in?

If I need the source code where can I find it as I checked on the site
but got lost?

Once I have everything correctly up and running how do integrate or
rather embed a video into an html page? - are there any guides on this?

Sorry if these questions are quite obvious but I am totally new to Nginx
and I’m still trying to understand the documentation.

Regards,

Kaya

On Sat, 2012-03-17 at 17:53 +0000, Kaya Saman wrote:

Is this the mp4 module that I need to be able to stream or is there an
embedded solution?

http://nginx.org/en/docs/http/ngx_http_mp4_module.html

Currently I’m running CentOS 6.2 as the server OS and have install Nginx
from the EPEL repo… does this contain the module or do I need to get
the source code and compile it in?

I would uninstall this and install from the official repositories
instead (they are newer):

http://wiki.nginx.org/Install#Official_Red_Hat.2FCentOS_packages

Regards,
Cliff

On 03/17/2012 06:41 PM, Cliff W. wrote:

On Sat, 2012-03-17 at 17:53 +0000, Kaya Saman wrote:

Is this the mp4 module that I need to be able to stream or is there an
embedded solution?
http://nginx.org/en/docs/http/ngx_http_mp4_module.html

Thanks. The links states:

" This module is not built by default, it should be enabled with the
|–with-http_mp4_module| configuration parameter. "

So does this mean that from the official repo stated below that
Nginx isn’t built with this module???

If not then where do I find the source code to get it or can I grab the
module from the repo, as in yum install mp4_module?

Currently I’m running CentOS 6.2 as the server OS and have install Nginx
from the EPEL repo… does this contain the module or do I need to get
the source code and compile it in?
I would uninstall this and install from the official repositories
instead (they are newer):

http://wiki.nginx.org/Install#Official_Red_Hat.2FCentOS_packages

Regards,
Cliff

Regards,

Kaya

On Sat, 2012-03-17 at 19:16 +0000, Kaya Saman wrote:

–with-http_mp4_module configuration parameter. "

So does this mean that from the official repo stated below that
Nginx isn’t built with this module???

It is. Here’s the output from “nginx -V” on one of my CentOS systems
with the official nginx installed:

–prefix=/etc/nginx/
–sbin-path=/usr/sbin/nginx
–conf-path=/etc/nginx/nginx.conf
–error-log-path=/var/log/nginx/error.log
–http-log-path=/var/log/nginx/access.log
–pid-path=/var/run/nginx.pid
–lock-path=/var/run/nginx.lock
–http-client-body-temp-path=/var/cache/nginx/client_temp
–http-proxy-temp-path=/var/cache/nginx/proxy_temp
–http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp
–http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp
–http-scgi-temp-path=/var/cache/nginx/scgi_temp
–user=nginx --group=nginx
–with-http_ssl_module
–with-http_realip_module
–with-http_addition_module
–with-http_sub_module
–with-http_dav_module
–with-http_flv_module
–with-http_mp4_module

^^^^^^^^^^^^^^^^^^^^^^

–with-http_gzip_static_module
–with-http_random_index_module
–with-http_secure_link_module
–with-http_stub_status_module
–with-mail
–with-mail_ssl_module
–with-file-aio
–with-ipv6
–with-cc-opt=‘-O2 -g -march=i386 -mtune=i686’

If not then where do I find the source code to get it or can I grab
the module from the repo, as in yum install mp4_module?

The source code is available at http://nginx.org

More information on Nginx can be found at http://wiki.nginx.org
(including links to the source).

Regards,
Cliff

Thanks a lot Cliff I really appreciate the help!

However as per the documentation it claims
{http://nginx.org/en/docs/http/ngx_http_mp4_module.html}:

"

location /video/ {
mp4;
mp4_buffer_size 1m;
mp4_max_buffer_size 5m;
}

"

as the configuration for the module.

I added the above to the nginx.conf file and now nginx won’t start so
I’m guessing that it’s been added to the wrong place??

Also I guess what I’m trying to find out more then anything else is if
Nginx will be able to serve up information like YouTube? By embedding
the video into an html page then streaming via web browser with
sufficient plugin or straight to a player such as Mplayer or Xine?

Is there any guide or howto on how to do this as the documentation seems
a little sparse!

Regards,

Kaya

Many thanks Cliff for your support!

Regards,

Kaya

On Sat, 2012-03-17 at 20:01 +0000, Kaya Saman wrote:

I added the above to the nginx.conf file and now nginx won’t start so
I’m guessing that it’s been added to the wrong place??

Checking your logs is somewhat better than guessing :wink: On CentOS
that’s probably /var/log/nginx/error.log.

Also I guess what I’m trying to find out more then anything else is if
Nginx will be able to serve up information like YouTube? By embedding
the video into an html page then streaming via web browser with
sufficient plugin or straight to a player such as Mplayer or Xine?

I believe the mp4 module is designed for use with Flash. Someone else
who has actually used it could probably offer a more informed opinion.

Is there any guide or howto on how to do this as the documentation seems
a little sparse!

I suspect it’s sparse because there’s not much to it on the Nginx-side
of things. If you are looking for a guide for the client-side as well,
I can only suggest Google or hope that someone here can offer more
assistance on that end.

Regards,
Cliff

Is there any guide or howto on how to do this as the documentation seems
a little sparse!

nginx and the mp4 module documentation is about the server side of
things only.

If you need documentation and solutions for the client side, take a look
at
JWPlayer [1], but remember its off-topic on this list. Longtailvideo has
forums and commercial support offerings, in case you need any support on
JWPlayer.

[1] JW Player: End-to-End Solution for Streaming & Monetizing Video

Nginx can’t write a website for you if that’s what you mean

It’s long hard work making a tube site, either pay someone or get
learning :slight_smile:


Richard

On 03/18/2012 12:39 PM, Lukas T. wrote:

[1] JW Player: End-to-End Solution for Streaming & Monetizing Video


nginx mailing list
[email protected]
nginx Info Page

Many thanks!

I actually discovered how to ‘server up’ video files using nginx:

 location /video/ {
     mp4;
     mp4_buffer_size     1m;
     mp4_max_buffer_size 5m;
 root   /usr/share/nginx/html;
 }

by putting the above into conf.d/default.conf

Now it all works fine and am able to access the video via mplayer.

Quick question… is building an html page then embedding a video into
it client side? I always considered that server side while my view of
client side was always just the browser and URL…

Regards,

Kaya

The primary reason for the mp4 module is to allow seeking of the video
before the whole file has been downloaded by flash - it’s all a nasty
workaround for flash being ****

Mp4 can be used in some browsers with html5 video tag (and most mobile
devices)
Otherwise you will have to use one of the flash video players, like
flowplayer or jwplayer

The nginx mp4 filter is only beneficial to the latter as it allows
pseudo-streaming in flash
Html5 will work fine without the mp4 module and indeed in other httpds,
as it uses the http range header (e.g. to seek the video, it just
“resumes” the download from a later point)

On 03/18/2012 07:39 PM, Richard K. wrote:

The primary reason for the mp4 module is to allow seeking of the video before
the whole file has been downloaded by flash - it’s all a nasty workaround for
flash being ****

Mp4 can be used in some browsers with html5 video tag (and most mobile devices)
Otherwise you will have to use one of the flash video players, like flowplayer
or jwplayer

The nginx mp4 filter is only beneficial to the latter as it allows
pseudo-streaming in flash
Html5 will work fine without the mp4 module and indeed in other httpds, as it
uses the http range header (e.g. to seek the video, it just “resumes” the download
from a later point)

Thanks the HTML5 video tag worked :slight_smile:

Regards,

Kaya

On 03/18/2012 04:59 PM, Richard K. wrote:

Nginx can’t write a website for you if that’s what you mean

No no that’s not what I meant :slight_smile:

A long time ago I played around with the Darwin Streaming Server from
Apple and vaguely recall the mechanism used to call up the .mov files in
an html page.

I was more referring to either a jscript or php snippet that would allow
for the embed… just something quick and easy. No biggie though!

It’s long hard work making a tube site, either pay someone or get learning :slight_smile:

I personally don’t intend to, the only knowledge I need is what I kinda
have already but would be nice to know the above (jscript or php)
too…

Regards,

Kaya