i4tv / gstreamill

encoder with hls output based on gstreamer.
GNU General Public License v3.0
248 stars 84 forks source link
encoder hls-live-streaming

Table of Contents

INTRODUCTION

Overview

gstreamill is an open source, based on gstreamer-1.0 with dvr support and hls output.

Highlight

Application

IP >-----+ 
         |   +------------+   +----> UDP
CVBS >---+   | gstreamill |   |                 +-- live
         +---+  with dvr  +---+---> M3U8(HLS) --+-- time shift (?timeshift=nnnn)
SDI >----+   +------+-----+   |                 +-- catch up (?start=yyyymmddhhmmss&end=yyyymmddhhmmss)
         |          |         +---> HTTP
LIVE >---+          |
                    |
     REST interface (json over http post)

Third-party Applications

INSTALL

gstreamill have been tested in ubuntu 16.04.2.

get source

git clone https://github.com/i4tv/gstreamill.git

install prerequisites

sudo apt-get install autoconf automake libtool libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libgstreamer-plugins-bad1.0-dev libaugeas-dev

Compile and install

./autogen.sh
./configure (--help)
make
make install

dist package

./make dist

USING GSTREAMILL

install prerequisites

sudo apt-get install gstreamer1.0-plugins-ugly gstreamer1.0-plugins-bad gstreamer1.0-plugins-good gstreamer1.0-plugins-base

B/S Management URL

http://gstreamill.ip:20118/admin/

Command line

default management port is 20118, use curl to invoke test job via management interface for example:

    curl -H "Content-Type: application/json" --data @examples/test.job http://localhost:20118/admin/start

Management interface

test.job is job description in json, can be found in examples directory.

job_name is value of the "name" field in job description.

Output

job name is the value of name of job description.

JOB DESCRIPTION

Job example:

/*
 * test job, videotestsrc and audiotestsrc
 */
{
    "name" : "test",
    "debug" : "gstreamill:3",
    "source" : {
        "elements" : {
            "videotestsrc" : {
                "caps" : "video/x-raw,width=720,height=576,framerate=25/1"
            },
            "audiotestsrc" : {
                "property" : {
                    "wave" : 8
                }
            }
        },
        "bins" : [
            "videotestsrc ! appsink name=video",
            "audiotestsrc ! appsink name=audio"
        ]
    },
    "encoders" : [
        {
            "elements": {
                "appsrc" : {
                    "property" : {
                        "format" : 3,
                        "is-live" : true
                    }
                },
                "x264enc" : {
                    "property" : {
                        "bitrate" : 1000,
                        "byte-stream" : true,
                        "threads" : 4,
                        "bframes" : 3
                    }
                },
                "faac" : {
                    "property" : {
                        "name" : "faac",
                        "outputformat" : 1
                    }
                },
                "appsink" : {
                    "property" : {
                        "sync" : false
                    }
                }
            },
            "bins" : [
                "appsrc name=video ! queue ! timeoverlay ! queue ! x264enc ! queue ! muxer.",
                "appsrc name=audio ! audioconvert ! audioresample ! voaacenc ! muxer.",
                "mpegtsmux name=muxer ! queue ! appsink"
            ]
        }
    ],
    "m3u8streaming" : {
        "version" : 3,
        "window-size" : 10,
        "segment-duration" : 3.00
    },
    "dvr_duration": 86400
}

JOB file structure:

{
    'name' : 'cctv2',
    'debug' : '3',
    'is-live' : false,
    'log-path' : '/home/zhangping/tmp/cctv2',
    'source' : {
        ...
    },
    'encoders' : [
        ...
    ],
    'm3u8streaming' : {
        ...
    },
    "dvr_duration": 86400
}

name : job name

debug : debug option, reference gst-launch gst-debug, optional.

is-live : true for live source, false otherwise, for example transcode, default is true.

log-path : dont log to default log direcotry for non-live source, log to log-path if it is presented.

source : source of encoders.

encoders : encoders.

m3u8streaming : m3u8 streaming

dvr_duration : dvr duration, seconds, it's optional.

structure of source:

"source" : {
    "elements" : {
        ...
    },
    "bins" : [
        ...
    ]
}

structure of elements:

"elements" : {
    "element" : {
        "property" : {
            ...
        },
        "caps" : "..."
    },
    ...
}

structure of bins:

"bins" : [
    bin,
    bin,
    ...
]

bins is an array of bin, syntax of bin is like gst-launch, for example:

[
    "udpsrc ! queue ! tsdemux name=demuxer",
    "demuxer.video ! queue ! mpeg2dec ! queue ! appsink name = video",
    "demuxer.audio ! mpegaudioparse ! queue ! mad ! queue ! appsink name = audio" 
]

in this example, first bin with tsdemux has sometimes pads, second and third bin link with first bin: demuxer.video and demuxer.audio. second bin with appsink named video and third bin with appsink named audio. source bins must have bin with appsink that is corespond endoders' source.

structure of encoders:

"encoders" : [
    encoder,
    ...
]

encoders is an array of encoder, encoder is an object, every encoder correspneds an encode output, that means gstreamill support mutilty bitrate output.

structure of encoder:

{
    "elements" : {
        ...
    },
    "bins" : [
        ...
    ],
    "udpstreaming" : "uri"
}

elements and bins is just the same as source structure in syntax, the differnce is encoder bins must have bins with appsrc element, appsrc must have name property, the value of name is the same as appsink name value in source bins. udpstreaming uri is udp streaming output uri, it's optional.

m3u8streaming is hls output, it's optional:

"m3u8streaming" : {
    "version" : 3,
    "window-size" : 10,
    "segment-duration" : 3.00,
}

There are examples in examples directory of source.

Talk about gstreamill on gstreamill or report a bug on issues page.

License

gstreamill is available under GPL v3. See the LICENSE file for more info.