Git Product home page Git Product logo

python-librtmp's Introduction

python-librtmp

http://img.shields.io/pypi/v/python-librtmp.svg?style=flat-square http://img.shields.io/pypi/dm/python-librtmp.svg?style=flat-square http://img.shields.io/travis/chrippa/python-librtmp.svg?style=flat-square

python-librtmp is a RTMP client library. It uses the implementation provided by librtmp via cffi.

Installation

The latest stable version is available to install using pip

sudo pip install python-librtmp

But you can also get the development version using Git:

git clone git://github.com/chrippa/python-librtmp.git
cd python-librtmp
sudo python setup.py install

Note

cffi 1.0 was released recently which contains significant changes. If you have an old version already installed you will have to manually upgrade it or you will get an error when attempting to install python-librtmp.

Dependencies

  • Python, at least version 2.6 or 3.3.
  • a C compiler capapable of building Python extensions, e.g. gcc
  • librtmp: The library including its headers (librtmp-dev or equivalent)
  • cffi: cffi depends on libffi and its headers (libffi-dev or equivalent)
  • On Python <3.4 the backport of singledispatch is also required.

Windows

python-librtmp (and cffi) has wheel packages (binaries) available on PyPi and can therefore be easily installed with pip 1.4+ without the need to compile anything:

> pip install python-librtmp

(on older pip versions you need to use --use-wheel)
> pip install --use-wheel python-librtmp

Features

Streaming

The most common use case of RTMP is to read a video stream from a server.

import librtmp

# Create a connection
conn = librtmp.RTMP("rtmp://your.server.net/app/playpath", live=True)
# Attempt to connect
conn.connect()
# Get a file-like object to access to the stream
stream = conn.create_stream()
# Read 1024 bytes of data
data = stream.read(1024)

Remote function calls

Here is a example of creating a Python function that can be used to call remote functions:

my_remote_method = conn.remote_method("MyRemoteMethod", block=True)
result = my_remote_method("some argument")

Waiting for the server to call our function:

# This will automatically name the function after it's Python name
@conn.invoke_handler
def my_add(a, b):
    return a + b

# Start waiting for calls
conn.process_packets()

You can also use custom function name instead:

@conn.invoke_handler("MyMath.MyAdd")

Instead of blocking forever when waiting for a call you can specify to wait only for a specific invoke and then stop blocking:

conn.process_packets(invoked_method="MyMath.MyAdd", timeout=30)

python-librtmp's People

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.