Code Monkey home page Code Monkey logo

slasher's Introduction

Slasher

A commmand-line tool and Python library for autonomous editing of livestreams via live chat activity.

Through Slasher, you (the chat member, not the creator) are the editor of the livestream! Through an ultra-simple algorithm, portions of a livestream where chat is unusually active are kept and concatenated together. This allows for the speedy (we are just downloading, processing, and creating text afterall) creation of highlights that your audience directly finds enjoying. Personally, I think that the highlights that my tool creates are quite fun to watch, and I at times forgot that they were created via a computer program!

Because of the nature of Slasher, the algorithm can occasionally cut off speech, take out chunks of long-running moments (singing), leave intervals without context. Luckily, Slasher can output project files compatible with video editors so that the editor is fully in control and can quickly integrate the tool into their workflow. Slasher will not be appropriate for all livestreams and editors, but it does what it can do really well and attempts to give the end-user as much control as they please!

With default settings (2x multiplier, 10-second intervals, zero delay), Slasher's filter mode can turn about one hour of content into seven minutes, making it easy to watch a two-or-three hour live stream during a lunch break, and quickly consume an 8-hour live stream in under an hour. Can't justify watching or editing a 24-hour livestream? Now you can! Don't care about occasionally awkward edits and just want a half-hour highlight half an hour after your livestream ends to get those sweet views? Be my guest! The possibilites with my tool should be quite endless, so go crazy!

Installation

Look to pip for what you desire:

pip install video-slasher

As a developer, clone the project and run poetry install.

Usage

Command-Line Interface

usage: slasher [-h] [--format {ffmpeg,ffsilencer,mlt}] [--output OUTPUT]
               [--duration DURATION] [--delay DELAY] [--start START]
               [--end END]
               {filter,top} ...

Leave the noise of VODs on the cutting room floor.

positional arguments:
  {filter,top}
    filter              remove intervals of a stream that don't meet a certain
                        comment threshold
        positional arguments:
          url                   a chat-downloader-compatible URL

        optional arguments:
          --multiplier MULTIPLIER, -m MULTIPLIER
                                intervals must have a number of messages greater than
                                the average times this (default: 2)

    top                 pick the top intervals from a stream sorted by
                        messages
        positional arguments:
          url                   a chat-downloader-compatible URL

        optional arguments:
          --amount AMOUNT, -a AMOUNT
                                 number of intervals you want to keep

optional arguments:
  -h, --help            show this help message and exit
  --format {ffmpeg,ffsilencer,mlt}, -f {ffmpeg,ffsilencer,mlt}
                        what output you want (default: mlt)
  --output OUTPUT, -o OUTPUT
                        where the format will be written to (default: stdout)
  --duration DURATION   how long an interval should be, uses Python's
                        timedelta syntax (default: ten seconds)
  --delay DELAY         how far back messages should be pushed back, used to
                        sync chat with stream, uses Python's timedelta syntax
                        (default: zero seconds)
  --start START         capture messages from this time, uses Python's
                        timedelta syntax (default: zero seconds)
  --end END             capture messages to this time, uses Python's timedelta
                        syntax (default: timedelta.max)

Python Library

The entirety of Slasher sans the command line app is less than 150 lines, is fully typed, and has docstrings that give you the gist of what each function does, so just read it!

Examples

Slasher comes with sensible defaults, so usage is as basic as:

python -m slasher filter https://www.twitch.tv/videos/1080642970
python -m slasher top https://www.twitch.tv/videos/1080642970
from slasher import Slasher
s = Slasher.from_url("https://www.twitch.tv/videos/1080642970")
s = s.filter()

If you want to write your results to a file:

python -m slasher --output intervals.mlt filter https://www.twitch.tv/videos/1080642970
with open("intervals.mlt", "w") as f:
    s.to_mlt(f)

For more examples of Python lib usage, see examples/

Formats

CLI: --format mlt

Python: Slasher.to_mlt

This is an XML document format compatible with the open-source multimedia framework MLT, and can be opened in compatible video editors such as Shotcut. I have no plans to support other video editors as most are expensive or are exclusive to macOS.

CLI: --format ffsilencer

Python: Slasher.to_ffsilencer

This is a basic plain-text format with a timesecond in seconds on the left and a duration in seconds on the right, like 2550 10. This is inspired by a Bash script I wrote to remove silence from videos with FFmpeg. Until I add some sort of "custom" option to FFsilencer, advanced users can feel free to download and use a modified version of FFsilencer I made for this project.

!FOR ADVANCED USERS!

CLI: --format ffmpeg

Python: Slasher.to_ffmpeg_filter_complex

This is an implementation of FFsilencer's filter complex creator in Python. The video and audio streams used are [outv] and [outa] respectively. With FFmpeg, use it like this:

ffmpeg -hide_banner -i $IN -filter_complex_script $SCRIPT -map [outv] -map [outa] $OUT

Resources

For info on how timedelta works, see the Python docs. To see what sites Slasher supports, see Chat Downloader

License

https://unlicense.org/

slasher's People

Contributors

supersonichub1 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 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.