Recording Twitch Live Stream

From Littledamien Wiki
Jump to navigation Jump to search

Streamlink[edit]

Source: Streamlink on GitHub

Can be installed with homebrew or pip.

Usage: [1]

$ streamlink --twitch-disable-ads -o path/to/output.ts https://twitch.tv/[twitchUser] best

The --twitch-disable-ads pauses recording during preroll and ad breaks in order to avoid discontinuity in the saved stream which interferes with playback in players such as VLC. [2]

Streamlink output format is MPEG transport stream (MPEG-TS). The output stream will need to be converted into a more usable format with a separate utility, e.g.:

$ ffmpeg -i yourvideoname.ts -c:v libx264 outputfilename.mp4

See also Twitch API and Python Twitch API.

Kick[edit]

Streamlink can also be used for kick.com streams.

The latest version of the program (5.5.1) currently does not support Kick streams natively.

Kick streams require a 3rd-party plugin to be installed.

This plugin is installed by copying a python script to the Streamlink plugins directory (~/Library/Application Support/streamlink/plugins/).

The plugin depends on the cloudscraper Python package, which can be installed with pip:

$ pip install cloudscraper

However, streamlink is installed with brew. Brew in turn relies on its own python installation, which is different from the system installation. (/usr/local/Cellar/python@3.x/3.x.x/Frameworks/Python.framework/Versions/3.x/lib/python3.x/)

When streamlink is run using brew's python install, cloudscraper isn't accessible. It's necessary to create a link to the cloudscraper packs installed via pip:

$ cd /usr/local/Cellar/python@3.x/3.x.x/Frameworks/Python.framework/Versions/3.x/lib/python3.x/
$ ln -s /Users/[USER_ACCOUNT]/.pyenv/versions/3.x.x/lib/python3.x/site-packages/cloudscraper ./cloudscraper

In addition to the cloudscraper package, I found that the Kick plugin also requires the requests_toolbelt package. Again, make a link to the system version of this package from within the brew distribution in the same way that the link was made for the cloudscraper package.

After these steps are taken, streamlink should be able to record a Kick stream:

$ streamlink o path/to/output.ts https://kick.com/[kickUser] best

Recording within VLC[edit]

Finding the link to the Twitch video[edit]

  • Load the Twitch stream in a Chrome browser.
  • Pause the video.
  • Right click on the page, not the video and select Inspect.
  • Open the Network tab in Chrome's Developer Tools window.
  • Start the Twitch stream.
  • Scroll down in the Network window until you see a resource displayed in red.
  • Copy the address of that resource.

Load the Twitch stream in VLC[edit]

  • Open VLC
  • File > Open Network
  • Paste the URL from the Twitch stream.
  • Click the Stream output option.
    • Settings
    • Select the location where the stream is saved under File.
  • This will save a video transport stream (*.ts) file.
  • The stream is not displayed automatically in the VLC window.
  • Stop streaming to the file using the stop button on the VLC transport.

Convert MPEG-TS to MP4[edit]

Handbrake - Open the .ts file. Set the output settings, e.g. format: MP4 File. Set the destination and click Start.

Identifying tracks[edit]

Shazam[edit]

Mac OS desktop app.

There is an option to "Auto Shazam" but that requires actually listening to the whole video. Other option is to skip around in the video to each track and then manually identify the track with Shazam.