This repository has been archived by the owner on Jul 21, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Live Stream Archiving
Isaac edited this page Apr 13, 2022
·
3 revisions
Live archiving includes:
- Video Download
- Chat Download
- Chat Render
Channels can be added to a "live watch" list from the web interface or the API. Channels in the list have their streams checked every 5 minutes if they are live. Once a channel is marked as live, the stream and chat will begin downloading. Once the stream ends, the chat is then rendered identical to the VOD chat rendering.
This system is useful for streamers that use dual audio or have VODs disabled on their channel.
Process
- Channels marked as "not live" are checked every 5 minutes against Twitch's Helix "Streams" API endpoint.
- If a channel is live, it is marked as live in the database and Streamlink is executed to begin downloading the live stream. More on why Streamlink is used below.
- Two seconds later, the chat begins to download using chat-downloader. The two second delay is for Streamlink to fetch the stream manifest and begin downloading.
- Once Streamlink stops receiving input from the stream (after 5 retries), it is decided that the stream is offline and both Streamlink and chat-downloader get killed.
- The downloaded stream format is
.ts
which needs to be converted tomp4
. Ffmpeg is executed to convert at this time. Once the conversion is completed ffprobe is used to get the stream duration and updates the entry in the database. - While the video gets converted, the downloaded chat is also being converted into a format that can be rendered.
- The chat rendering gets executed and the rest of the process is identical to a normal VOD archive.
Notes
- View count does not update when live archiving.
- If the streamer abruptly goes offline (internet went out), the video download will retry for 5 times. If it fails to download after 5 attempts it will mark the stream as offline. If the streamer comes back online, the new stream will be archived when the check performs again every 5 minutes.
- The stream is downloaded using Streamlink instead of ffmpeg as Streamlink has the ability to remove ads.
- Chat is downloaded using chat-downloader then converted into a format that TwitchDownloader can use to render.