Return to Level1Techs.com

Twitch.tv - watch past broadcasts with VLC

tutorial
web
#1

You can watch prerecorded videos from Twitch.tv in you video player of choice without any additional software. Use cases may be different. I decided to look into it because dreaded error #2000 was popping up every 10 minutes and would cut off the stream without saving last position. It doesn’t seem to happen with this method.

Step #1 - get stream playlist file

Twitch streams are served in 10 second clips and tied together with a m3u8 format playlist. In order to find the playlist you need to open developer console in your browser and navigate to the video page. I will provide Chrome instruction, but other browsers should work sufficiently similar.


Under “Network” tab you should see a list of objects being requested by the page. You will see a file, or tw called index-dvr.m3u8. You need to download it as well as copy it’s link address. In Chrome you can do it by right clicking the file and choosing “Copy” -> “Copy link address”.

Step #2 - Make it playable by local media player

image

If you open the playlist file with a text editor of your choice, you will see a long list of numbered file names ending in .ts. These are the 10 second chunks that the server refers to when serving the content. However, those files are located relative to the playlist itself. Luckily, we know where we got the playlist so you just need to append that address to the filename. Just before you do that, lets look at that address.
(Example)

https://vod-secure.twitch.tv/8f6ba87341845cda3e48_channel_name_34721465552_1238758894/720p60/index-dvr.m3u8

This address can be split into 4 parts:

Server URL: https://vod-secure.twitch.tv
Stream unique ID: 8f6ba87341845cda3e48_channel_name_34721465552_1238758894
Source video quality: 720p60
File name: index-dvr.m3u8

You can manually change the stream quality from available options on stream page, or change it to chunked for original quality.

All is left to do is to append full path to each .ts chunk in the playlist file. You can use any language or utility to do it, I will demonstrate a way to do it with sed. Lets say I want a playlist in 720p 60fps quality.

sed -i '/.ts$/ s/^/https:\/\/vod-secure.twitch.tv\/8f6ba87341845cda3e48_channel_name_34721465552_1238758894\/720p60\//' index-dvr.m3u8

I navigate to the folder with playlist file and execute the above command.

sed -i - stream editing utility. In this context it preforms a search & replace kind of function
/.ts$/ - search for lines ending with .ts
s/^/ - substitute at the beginning of each line found with previous criteria
https:\/\/vod-secure.twitch.tv\/8f6ba87341845cda3e48_channel_name_34721465552_1238758894\/720p60\// - full path to the file. NOTE: each forward slash in the url needs to be ‘escaped’ with a backslash before it.

You should end up with something like this for every line in the playlist file:

#EXTINF:10.000,
https://vod-secure.twitch.tv/8f6ba87341845cda3e48_channel_name_34721465552_1238758894/720p60/0.ts

Step #3 - PROFIT

Just start it with your video player of choice and enjoy smooth playback of the steam and every benefit that comes from using your own media player such as audio/video filters and so on. Feel free provide your own solutions in your language of choice or even a more complete, one button approach in the comments.

3 Likes