TwitchCompilationCreator
A fully automated system that transforms Twitch clips into gaming compilations
Install / Use
/learn @ContentAutomation/TwitchCompilationCreatorREADME
About
This is our approach of automatically creating compilations of twitch clips (focused on gaming). We are very interested in YouTube, Twitch and Programming so we started this as an experiment, now a few months later we have to say it worked!
What did we achieve?
- We automatically uploaded over 100 videos to our YouTube channel without any human interaction
- One video got quite some traction by getting 2155 views and 48 likes at that point we had 0 Subscribers and it was the 8th video of the channel
- All our uploads combined got over 10k views
- We didn't receive a single comment indicating the use of bots
So why do we publish this now instead of making money with it?
- We came to the conclusion that we'd need to further optimize the videos to grow the channel which would require sophisticated and computationally expensive neural networks.
- We do not own the copyright of the clips so theoretically somebody could claim the video. To legally monetize the content, we'd need to add value to the clips like funny comments with a good text-to-speech framework.
- The language of some clips is declared as English by Twitch, even though the spoken language is not English. To filter those clips, a computationally expensive neural network for language-detection is required.
It was only an experiment without the direct goal of making money with it. Additionally, we think it is more valuable for us as a reference. If you are encountering any problems when running the code, feel free to open an Issue or a Pull Request with a possible fix.
Results
Example Video Screenshot | Example Thumbnail
:----------------------------------:|:-------------------------:
| ![]()
Example Description
[Fortnite] Twitch Highlights #10 | Fails, Satisfying/Funny Moments & Epic Wins!
🔔 SUBSCRIBE FOR MORE FORTNITE FAILS/WINS!
https://www.youtube.com/channel/UCqq27nknJ3fe5IvrAbfuEwQ?sub_confirmation=1
Welcome back to episode 10 of Daily Gaming Highlights | Fortnite!
We have some insane clips this episode.
If you liked and enjoyed the video be sure to leave a like and subscribe for more Fortnite content!
We upload a Fortnite video every monday once a week.
Also be sure to comment letting us know which your favorite clip was 😄
Featured Playlists:
• Daily Gaming Highlights: https://www.youtube.com/playlist?list=PLhOg0bYb-2IKbbV4rHerrtlWArm14bXdI
• Fortnite Highlights: https://www.youtube.com/playlist?list=PLhOg0bYb-2IICWc4MB-ZetkKGMTSvanye
🎬Featured clips/streamers:
Streamer1: https://clips.twitch.tv/AwkwardProtectiveDoritosChip
Streamer2: https://clips.twitch.tv/WimpyGleamingTTours
00:00 Streamer1
00:11 Streamer2
Golden Gorilla does not have the copyrights for the used clips.
If you are within a video and would like to get it removed please email us:
highlightsforgaming@gmail.com
#GoldenGorilla #Fortnite #Fails #FunnyMoments #EpicMoments #Wins #EpicWins
#fortnitebattleroyale #season4 #twitch
Requirements
This project requires Poetry to install the required dependencies. Check out this link to install Poetry on your operating system.
Make sure you have installed Python 3.10! Otherwise Step 3 will let you know that you have no compatible Python version installed.
Additionally, this project requires ffmpeg and imagemagick.
There are a few additional steps depending on the operating system that are listed below:
Windows
- Poetry
- installing might throw errors which can be resolved by following this solution
- you should use pip version ≥ 20.2.3 to avoid additional problems
- ffmpeg
- has to be added to the path, so it can be accessed directly with the streamlink command
- imagemagick
- you have to change the config_default as described here
Linux
- imagemagick
- make sure the line
<policy domain="path" rights="none" pattern="@*"/>is NOT present in the imagemagick policy config (/etc/ImageMagick-6/policy.xmlon Debian/Ubuntu). Comment out this line if it is found in the file to ensure that imagemagick is not restricted by the path access policy.*
- make sure the line
Setup
- Clone/Download this repository
- Navigate to the root of the repository
- Run
poetry installto create a virtual environment with Poetry - Follow the Twitch Api Docs until you get your own CLIENT_ID and CLIENT_SECRET
- Optional: Follow the YouTube Data API Docs until you receive an API key
- Insert your Twitch(CLIENT_ID, CLIENT_SECRET) and optionally your YouTube(YT_API_KEY) into the config.py. It should look like the following <br>
<span style="color:red">HINT: The example keys do not work</span>.
# For the Twitch API
CLIENT_ID = "o42tebpdzmj5z811iycgcpmd82on24"
CLIENT_SECRET = "owdgx64t1dodleiuo49e5rg7rvk5iq"
DIRECTORIES = dict(raw_clips_dir="rawClips", compilation_dir="compilation")
# For the YouTube API
# Optional: Only required if you want continuous numbering (e.g. Example Video Title #1, #2, ..., #N) for your videos
# Note: The number (#N) is determined by the number of items in a given YouTube playlist (declared in metadata_config)
YT_API_KEY = "h5UYdzJHeZNWLTgGteh0J68k7icp9jp9vPJlbzF"
- Run
poetry run python main.pyto run the program. Alternatively you can runpoetry shellfollowed bypython main.py - Enjoy :)
Script Explanations
APIHandler.py
This class contains static methods to handle all API request for the Twitch and YouTube API.
Clip.py
This dataclass is used to convert json data from the Twitch API to Clip objects. This makes the data easier accessible within the python code.
ClipHandler.py
This class determines which Twitch clips the compilation will be made of and process them. It will do the following:
- call the Twitch API to get the clip metadata
- check if clips are ingame by using a neural network
- process 100 clip metadata at a time and fetch more metadata if necessary
- download the clips one-by-one
ClipCompilationCreator.py
This class will use the clips from the ClipHandler to create a compilation of all clips with a logo and the name of the clip creator as overlay. It will do the following:
- load all clips based on the metadata file
- create an overlay text for each clip
- composite all clips with their text and the logo
- compress the audio of the compilation so the sound is equaly high for the whole compilation
- render the finished compilation
MetadataHandler.py
This class will handle/create all metadata that is needed for a YouTube upload. It will do the following:
- handle the loading, saving, and storage of the metadata
- on every first load it will refresh the metadata. If clips got deleted in the raw_clips_dir it will remove them automatically from the metadata
- use a template to create YouTube title and description based on the metadata_config of the game and the metadata of that specific compilation
- create a thumbnail using a fr
