Skip to main content

Package to handle real-time frames or audio segments from a twitch stream

Project description

Build Status codecov PyPI version fury.io

Description

This package allows to extract in real-time frames or audio segments of a twitch stream as a numpy array. It heavily relies on FFmpeg to decode on-the-fly and asynchronously the stream. Then the package stocks the frames or the audio segments into a fifo.

Requirements

  • FFmpeg
  • python 3.7+

This code has only been tested on Ubuntu 20.04, it might requires some tweaks to make it compatible with Windows or MacOSX

Installation

Install using pip for stable release,

pip install twitchrealtimehandler

For latest development release,

pip install git+git://github.com:adrz/twitch-realtime-handler.git

Usage

from twitchrealtimehandler import (TwitchAudioGrabber,
                                   TwitchImageGrabber)
import numpy as np

audio_grabber = TwitchAudioGrabber(
    twitch_url="https://www.twitch.tv/jeanmassietaccropolis",
    blocking=True,  # wait until a segment is available
    segment_length=2,  # segment length in seconds
    rate=16000,  # sampling rate of the audio
    channels=2,  # number of channels
    dtype=np.int16  # quality of the audio could be [np.int16, np.int32, np.float32, np.float64]
    )

audio_segment = audio_grabber.grab()
audio_grabber.terminate()  # stop the transcoding

image_grabber = TwitchImageGrabber(
    twitch_url="https://www.twitch.tv/jeanmassietaccropolis",
    quality="480p",  # quality of the stream could be ["160p", "360p", "480p", "720p", "720p60", "1080p", "1080p60"]
    blocking=True,
    rate=10  # frame per rate (fps)
    )

frame = image_grabber.grab()
image_grabber.terminate()  # stop the transcoding

Examples

Requirements

Dependencies for face_recognition package:

sudo apt-get update
sudo apt-get install build-essential cmake
sudo apt-get install libopenblas-dev liblapack-dev 
sudo apt-get install libx11-dev libgtk-3-dev
sudo apt-get install python3 python3-dev python3-pip
pip install -r requirements-examples.txt

Real-time face detection

python examples/realtime-face-detection.py --twitch-url https://twitch.tv/yourfavouritetwitcher

face-detection-senat

Real-time transcript

python examples/realtime-transcript.py --twitch-url https://twitch.tv/yourfavouritetwitcher

Known issues

twitch-third-party

If you encounter this image, it means that twitch knows your not watching from its website. You'll get this message for a few seconds and the stream will resume.

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

twitchrealtimehandler-0.0.2.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

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

twitchrealtimehandler-0.0.2-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file twitchrealtimehandler-0.0.2.tar.gz.

File metadata

  • Download URL: twitchrealtimehandler-0.0.2.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.1.post20201107 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5

File hashes

Hashes for twitchrealtimehandler-0.0.2.tar.gz
Algorithm Hash digest
SHA256 b25125d3faf0f7c15e9402484426bccf40767ad80154919d9f2119896e00d9b0
MD5 fd042b1eeb929a383f1d2998006a65bf
BLAKE2b-256 910ae8a2a06c2363ee552e7dae1418ef7bc26e8f1a10281c515976077db69abc

See more details on using hashes here.

File details

Details for the file twitchrealtimehandler-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: twitchrealtimehandler-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 5.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.1.post20201107 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5

File hashes

Hashes for twitchrealtimehandler-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 77dedb5f4fe480ab97652835c06b5a8f34f5666bc4394f9d285a29416fbd216b
MD5 f756cf725ddb064c108651e34e4a893a
BLAKE2b-256 88d0cc3ff58de400d4806a93616e907bdec0452845486c4a4ac3656cd8c5fb28

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