Getting started with nginx rtmp


Download, build and install

CD to build directory (home)

[/crayon]
Download & unpack latest nginx-rtmp (you can also use http)

[/crayon]
Download & unpack nginx (you can also use svn)

[/crayon]
Build nginx with nginx-rtmp

[/crayon]
For nginx 1.3.4-1.5.0 more options are needed

[/crayon]

Set up live streaming

To set up RTMP support you need to add rtmp{} section to nginx.conf (can be found in PREFIX/conf/nginx.conf). Stock nginx.conf contains only http{} section.

Use this nginx.conf instead of stock config:

[/crayon]

Statistics

Navigate your browser to http://localhost:8080/stat to see current streaming statistics, connected clients, bandwidth etc.

Publishing with ffmpeg

The easiest way to publish live video stream is using ffmpeg (or avconv). It’s already installed on most systems and easy to install on others.

RTMP supports only a limited number of codecs. The most popular RTMP video codecs are H264, Sorenson-H263 (aka flv) and audio codecs AAC, MP3, Nellymoser, Speex. If your video is encoded with these codecs (the most common pair is H264/AAC) then you do not need any conversion. Otherwise you need to convert video to one of supported codecs.

We’ll stream test file /var/videos/test.mp4 to server with ffmpeg.

Streaming without conversion (given test.mp4 codecs are compatible with RTMP)

[/crayon]
Streaming and encoding audio (AAC) and video (H264), need libx264 and libfaac

[/crayon]
Streaming and encoding audio (MP3) and video (H264), need libx264 abd libmp3lame

[/crayon]
Streaming and encoding audio (Nellymoser) and video (Sorenson H263)

[/crayon]

Publishing video from webcam

[/crayon]

Playing with ffplay

[/crayon]

Publishing and playing with flash

See test/rtmp-publisher directory for test flash applets and html.

Leave a comment

Your email address will not be published. Required fields are marked *