Getting started with nginx rtmp

Download, build and install

CD to build directory (home)

cd /usr/build

Download & unpack latest nginx-rtmp (you can also use http)

git clone git://github.com/arut/nginx-rtmp-module.git

Download & unpack nginx (you can also use svn)

wget http://nginx.org/download/nginx-1.2.4.tar.gz
tar xzf nginx-1.2.4.tar.gz
cd nginx-1.2.4

Build nginx with nginx-rtmp

./configure --add-module=/usr/build/nginx-rtmp-module
make
make install

For nginx 1.3.4-1.5.0 more options are needed

./configure --add-module=/usr/build/nginx-rtmp-module --with-http_ssl_module
make
make install

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:

#user  nobody;
worker_processes  1;

error_log  logs/error.log debug;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;
    keepalive_timeout  65;

    server {
        listen       8080;
        server_name  localhost;

        # sample handlers
        #location /on_play {
        #    if ($arg_pageUrl ~* localhost) {
        #        return 201;
        #    }
        #    return 202;
        #}
        #location /on_publish {
        #    return 201;
        #}

        #location /vod {
        #    alias /var/myvideos;
        #}

        # rtmp stat
        location /stat {
            rtmp_stat all;
            rtmp_stat_stylesheet stat.xsl;
        }
        location /stat.xsl {
            # you can move stat.xsl to a different location
            root /usr/build/nginx-rtmp-module;
        }

        # rtmp control
        location /control {
            rtmp_control all;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
}

rtmp {
    server {
        listen 1935;
        ping 30s;
        notify_method get;

        application myapp {
            live on;

            # sample play/publish handlers
            #on_play http://localhost:8080/on_play;
            #on_publish http://localhost:8080/on_publish;

            # sample recorder
            #recorder rec1 {
            #    record all;
            #    record_interval 30s;
            #    record_path /tmp;
            #    record_unique on;
            #}

            # sample HLS
            #hls on;
            #hls_path /tmp/hls;
            #hls_sync 100ms;
        }

        # Video on demand
        #application vod {
        #    play /var/Videos;
        #}

        # Video on demand over HTTP
        #application vod_http {
        #    play http://localhost:8080/vod/;
        #}
    }
}

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)

ffmpeg -re -i /var/Videos/test.mp4 -c copy -f flv rtmp://localhost/myapp/mystream

Streaming and encoding audio (AAC) and video (H264), need libx264 and libfaac

ffmpeg -re -i /var/Videos/test.mp4 -c:v libx264 -c:a libfaac -ar 44100 -ac 1 -f flv rtmp://localhost/myapp/mystream

Streaming and encoding audio (MP3) and video (H264), need libx264 abd libmp3lame

ffmpeg -re -i /var/Videos/test.mp4 -c:v libx264 -c:a libmp3lame -ar 44100 -ac 1 -f flv rtmp://localhost/myapp/mystream

Streaming and encoding audio (Nellymoser) and video (Sorenson H263)

ffmpeg -re -i /var/Videos/test.mp4 -c:v flv -c:a nellymoser -ar 44100 -ac 1 -f flv rtmp://localhost/myapp/mystream

Publishing video from webcam

ffmpeg -f video4linux2 -i /dev/video0 -c:v libx264 -an -f flv rtmp://localhost/myapp/mystream

Playing with ffplay

ffplay rtmp://localhost/myapp/mystream

Publishing and playing with flash

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

Supporting DXVA 2.0 in DirectShow

This thread is direct forward from Microsoft MSDN website: http://technet.microsoft.com/zh-cn/aa965245

Easlier in this month, I was researching hardware video encoding/decoding supports for Linux base environments, which involves Intel Media SDK & VA-API(libva).

Happen to see this DXVA related post in MSDN, so I decided to copy it to my blog.

This topic describes how to support DirectX Video Acceleration (DXVA) 2.0 in a DirectShow decoder filter. Specifically, it describes the communication between the decoder and the video renderer. This topic does not describe how to implement DXVA decoding.

Continue reading “Supporting DXVA 2.0 in DirectShow”

Get AAC sampleRate/channels setting from H.245 terminalCapabilitySet

I’m new to H323, so if there something went wrong, please let me know it. I’ll be very apprieciated.

The information in H.245 terminalCapabilitySet is really sucked. As a newbie, I have no idea what it is whatever represented in the collapsing & nonCollapsing. Continue reading “Get AAC sampleRate/channels setting from H.245 terminalCapabilitySet”

Make your VLC player connecting RTSP streams default with RTP over TCP mode

Make your VLC player connecting RTSP streams default with RTP over TCP mode

VLC media palyer version: 2.0.8 Twoflower

Follow these steps to set your default setting:

Tools –> Preferences –> Input & Codecs

Find “Network” settings, and check RTP over RTSP (TCP) option, then restart/reopen your rtsp network stream, done.

Make your VLC player connecting RTSP streams default with RTP over TCP mode
Make your VLC player connecting RTSP streams default with RTP over TCP mode

If you capture the RTSP SETUP request buffer, your should see a command like this:
SETUP rtsp://192.168.1.106:5554/1/trackID=1 RTSP/1.0
CSeq: 4
User-Agent: LibVLC/2.0.8 (LIVE555 Streaming Media v2013.08.06)
Transport: RTP/AVP/TCP;unicast;interleaved=0-1

Failed to install Visual Studio 2010 on Win7

I bought myself a new notebook last Saturday, and installed a lot develop softwares on it.

But when I tried to install Visual Studio 2010, I got a error like this:

[code]

[08/06/13,23:08:05] Microsoft .NET Framework 4: [2] Error code -939523550 for this component is not recognized.
[08/06/13,23:08:05] Microsoft .NET Framework 4: [2] Component Microsoft .NET Framework 4 returned an unexpected value.
[08/06/13,23:08:08] VS70pgui: [2] DepCheck indicates Microsoft .NET Framework 4 is not installed.
[08/06/13,23:08:08] VS70pgui: [2] DepCheck indicates Microsoft Visual Studio Macro Tools was not attempted to be installed.
[08/06/13,23:08:09] VS70pgui: [2] DepCheck indicates TFS Object Model (x86) was not attempted to be installed.
[08/06/13,23:08:09] VS70pgui: [2] DepCheck indicates .NET Framework 4 Multi-Targeting Pack was not attempted to be installed.
[08/06/13,23:08:09] VS70pgui: [2] DepCheck indicates Microsoft Visual Studio 2010 Ultimate – ENU was not attempted to be installed.
[08/06/13,23:08:10] VS70pgui: [2] DepCheck indicates Microsoft Visual Studio 2010 Tools for Office Runtime (x86) was not attempted to be installed.
[08/06/13,23:08:10] VS70pgui: [2] DepCheck indicates Crystal Reports templates for Visual Studio 2010 was not attempted to be installed.
[08/06/13,23:08:10] VS70pgui: [2] DepCheck indicates Microsoft SQL Server Compact 3.5 SP2 (x86) ENU was not attempted to be installed.
[08/06/13,23:08:10] VS70pgui: [2] DepCheck indicates Visual Studio 2010 Tools for SQL Server Compact 3.5 SP2 ENU was not attempted to be installed.
[08/06/13,23:08:10] VS70pgui: [2] DepCheck indicates Microsoft Sync Framework Runtime v1.0 (x86) ENU was not attempted to be installed.
[08/06/13,23:08:11] VS70pgui: [2] DepCheck indicates Microsoft Sync Services for ADO.NET v2.0 (x86) ENU was not attempted to be installed.
[08/06/13,23:08:11] VS70pgui: [2] DepCheck indicates Microsoft Sync Framework Services v1.0 (x86) ENU was not attempted to be installed.
[08/06/13,23:08:11] VS70pgui: [2] DepCheck indicates Microsoft Sync Framework SDK v1.0 (x86) ENU was not attempted to be installed.
[08/06/13,23:08:11] VS70pgui: [2] DepCheck indicates Microsoft Visual Studio 2010 Performance Collection Tools (x86) was not attempted to be installed.
[08/06/13,23:08:12] VS70pgui: [2] DepCheck indicates Microsoft SQL Publishing Wizard 1.4 was not attempted to be installed.
[08/06/13,23:08:12] VS70pgui: [2] DepCheck indicates Microsoft SQL Server System CLR Types was not attempted to be installed.
[08/06/13,23:08:12] VS70pgui: [2] DepCheck indicates Microsoft SQL Server 2008 R2 Management Objects was not attempted to be installed.
[08/06/13,23:08:13] VS70pgui: [2] DepCheck indicates Microsoft SQL Server 2008 R2 Data-Tier Application Framework was not attempted to be installed.
[08/06/13,23:08:13] VS70pgui: [2] DepCheck indicates Microsoft SQL Server 2008 R2 Data-Tier Application Project was not attempted to be installed.
[08/06/13,23:08:13] VS70pgui: [2] DepCheck indicates Microsoft SQL Server 2008 R2 Transact-SQL Language Service was not attempted to be installed.
[08/06/13,23:08:13] VS70pgui: [2] DepCheck indicates Microsoft Visual Studio 2010 ADO.NET Entity Framework Tools was not attempted to be installed.
[08/06/13,23:08:14] VS70pgui: [2] DepCheck indicates Microsoft Help Viewer 1.0 x86 was not attempted to be installed.

[/code]

After searched on Google, found a solution out which is :

1. Download  .NET Framework 4 from http://www.microsoft.com/downloads/en/details.aspx?FamilyID=0a391abd-25c1-4fc0-919f-b21f31ab88b7 and install it separately.

2. After you have installed it, download .NET Framework Verification Tool to verify if .NET Framework are installed correctly on your machine or not. Click here: http://blogs.msdn.com/b/astebner/archive/2008/10/13/8999004.aspx

3. After you have installed it successfully, please run VS installer as Administrator and try to install it again.

July 2013: Bad thing happens

At the end of June, I got my left foot hurt while playing badminton. Just a few day later, I was ran over by a moto bike, and got my right foot hurt too. But comparing to what I encountered in the last year, what happened to me now are just nothing.
BTW: Alex Chang, one former colleague in UniSVR, also had a bad lucky in the last weekend, https://www.facebook.com/profile.php?id=100000278584731.

Bad thing happens, you can choose to pity for yourself, to freak out, or run away from the things happened to you, and you can choose to hide yourself in a freezer temporary(It was the hottest July ever in Shanghai), but being a shirker can only keep you away from the pain/sad for a momont, one day or another you need to face it. So, why not be more blandly, just wait and see could it be sader? Then maybe it’s a starter of lucky.

As usual, my niece came to Shanghai for her summer vacation. She’ll be a junior high student later this year, but she’s already taller than lucy now.

My little uncle, and my brother in law are busy seeing doctors for their legs, wish they best of lucks.