Skip to main content

Python bindings for librtmp, built with cffi

Project description

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 Python interface to librtmp. It uses cffi to interface with the C library librtmp.

Installation

The latest stable version is available to install using pip:

# pip install cffi
# 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
# pip install cffi
# python setup.py install

Dependencies

  • a compiler, e.g gcc

  • librtmp: The library including it’s headers (librtmp-dev). Only the official librtmp is supported, patched versions such as librtmp-ksv may not work.

  • cffi: The setup.py script currently depends on cffi being installed. Therefore you need to install it before installing this library. cffi also depends on libffi and it’s headers (libffi-dev)

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 --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)

History

0.2.2 (2015-04-15)

  • Fixed proxy not being used by librtmp.

  • Added support for Cygwin, patch by @schrobby. (#17)

0.2.1 (2014-09-01)

  • Fixed expected bytes type on Python 2.

  • Fixed singledispatch dependency condition.

0.2.0 (2014-04-07)

  • RTMPError now inherits from IOError.

  • Fixed MSVC build.

  • Added librtmp.so.1 to library paths, patch by Athanasios Oikonomou. (#4)

  • Added librtmp.dylib to library paths, patch by Will Donohoe. (#6)

0.1.2 (2013-10-08)

  • Fixed compilation issue on some platforms.

  • Fixed AMF issue on older librtmp versions. (#1)

0.1.1 (2013-09-25)

  • Fixed packaging issues.

0.1.0 (2013-09-23)

  • First release on PyPI.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

python-librtmp-0.2.2.tar.gz (25.3 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

python_librtmp-0.2.2-cp34-none-win32.whl (34.6 kB view details)

Uploaded CPython 3.4Windows x86

python_librtmp-0.2.2-cp33-none-win32.whl (34.6 kB view details)

Uploaded CPython 3.3Windows x86

python_librtmp-0.2.2-cp27-none-win32.whl (34.4 kB view details)

Uploaded CPython 2.7Windows x86

File details

Details for the file python-librtmp-0.2.2.tar.gz.

File metadata

File hashes

Hashes for python-librtmp-0.2.2.tar.gz
Algorithm Hash digest
SHA256 4586f043a1071a189f16cadabb4056569bd083adaf8b1e17187fe2210699a765
MD5 ac57c566f7e40d6e215715a7db2ced19
BLAKE2b-256 6e312eedced94a4c1b5f589d76c599e9a035c7096b6c926d9ac606519f48024f

See more details on using hashes here.

File details

Details for the file python_librtmp-0.2.2-cp34-none-win32.whl.

File metadata

File hashes

Hashes for python_librtmp-0.2.2-cp34-none-win32.whl
Algorithm Hash digest
SHA256 cf59211f72adb25ce47fe574e36fe05d15faeab1085168bb6a01ae0632989c8f
MD5 749fbe10ef10bbb11d5e2c5af2693f67
BLAKE2b-256 a7755bee7a43693d1eb2724c820e93ad3ad73351865205dbfcb83a0dc4895ab9

See more details on using hashes here.

File details

Details for the file python_librtmp-0.2.2-cp33-none-win32.whl.

File metadata

File hashes

Hashes for python_librtmp-0.2.2-cp33-none-win32.whl
Algorithm Hash digest
SHA256 3cb3ad9b91f5ce513e19afc167254065da4f95e5f6be34c4be13c7dee77d0360
MD5 5a5b1f6cf49a6cd2d80589ebfe3684df
BLAKE2b-256 e1e77364c3c8b52004343ac45a610af11709fd8fed141cdf56ec099d1cee0d8f

See more details on using hashes here.

File details

Details for the file python_librtmp-0.2.2-cp27-none-win32.whl.

File metadata

File hashes

Hashes for python_librtmp-0.2.2-cp27-none-win32.whl
Algorithm Hash digest
SHA256 73b0b90a0a37d3635393eab7519bb506bc2aacec9bda65ba03843787f61e6e5f
MD5 0eb965e88f1c31d1a59a175575309601
BLAKE2b-256 5f1245ef962b54fa775ede47bc40707d9a69c8707005de863e30b2068c6b1507

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page