Git Product home page Git Product logo

twitch-realtime-handler's Introduction

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.

twitch-realtime-handler's People

Contributors

adrz avatar

Stargazers

 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.