Recording Twitch Live Stream: Difference between revisions

From Littledamien Wiki
Jump to navigation Jump to search
Tag: wikieditor
No edit summary
Tag: wikieditor
 
(7 intermediate revisions by the same user not shown)
Line 2: Line 2:


Source: [https://streamlink.github.io/ Streamlink on GitHub]
Source: [https://streamlink.github.io/ Streamlink on GitHub]
Can be installed with homebrew or pip.
Usage: <ref>[https://streamlink.github.io/cli.html Streamlink CLI] - GitHub</ref>
<syntaxhighlight lang="bash">
$ streamlink --twitch-disable-ads -o path/to/output.ts https://twitch.tv/[twitchUser] best
</syntaxhighlight>
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. <ref>[https://github.com/streamlink/streamlink/issues/3210#issue-710685043 Twitch.tv embedded ads] - GitHub</ref>
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.:
<syntaxhighlight lang="bash">
$ ffmpeg -i yourvideoname.ts -c:v libx264 outputfilename.mp4
</syntaxhighlight>
See also [https://dev.twitch.tv/docs/api/ Twitch API] and [https://pytwitchapi.readthedocs.io/en/stable/ Python Twitch API].
=== Kick ===
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 [https://github.com/nonvegan/streamlink-plugin-kick 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`:
<syntaxhighlight lang="bash">
$ pip install cloudscraper
</syntaxhighlight>
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: 
<syntaxhighlight lang="bash">
$ 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
</syntaxhighlight>
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:
<syntaxhighlight lang="bash">
$ streamlink o path/to/output.ts https://kick.com/[kickUser] best
</syntaxhighlight>


== Recording within VLC ==
== Recording within VLC ==
Line 27: Line 78:
* Stop streaming to the file using the stop button on the VLC transport.
* Stop streaming to the file using the stop button on the VLC transport.


== Convert the *.ts file to a different format ==
== Convert MPEG-TS to MP4 ==
 
'''Handbrake''' - Open the .ts file. Set the output settings, e.g. '''format''': `MP4 File`. Set the '''destination''' and click '''Start'''.
 
== Identifying tracks ==
 
=== Shazam ===
 
Mac OS desktop app.


'''Handbrake''' - Open the .ts file. Set the output settings, e.g. ''format''': `MP4 File`. Set the '''destination''' and click '''Start'''.
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.

Latest revision as of 03:18, 20 July 2023

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.