A tool to download Instagram live streams.
Project description
instarec: Instagram Livestream Downloader
instarec is a Python-based command-line tool for downloading Instagram livestreams. It is designed to be robust, featuring concurrent downloading of video and audio segments, recovery of past segments, and automatic merging of the final video file.
Features
- Interactive Quality Selection: Interactively choose from available video and audio stream qualities.
- Past and Live Recording: Downloads both previously broadcasted segments and continues to record the livestream in real-time.
- Optimized Performance: Downloads segments efficiently and merges the final video without needing to re-encode.
- Segment Loss Detection: Can generate a summary file detailing any missing segments from the download.
- Flexible Usage: Use either a direct
.mpdmanifest URL or an Instagram username to start a download. - Customizable: Offers a wide range of command-line arguments to tailor the downloading process.
Installation
Prerequisites
You must have ffmpeg and ffprobe installed and accessible in your system's PATH. These are required for merging the final video and audio files.
Standard Installation
The recommended way to install instarec is via pip:
pip install instarec
This will install the tool and make the instarec command available in your terminal.
Usage
You can start a download by providing either a direct .mpd URL for a livestream or an Instagram username.
Basic Examples
-
Download from an MPD URL with interactive quality selection and mux to MKV:
instarec <mpd_url> my_video.mkv -i
-
Download from an MPD URL with the best available quality and mux to MP4:
instarec <mpd_url> my_video.mp4
-
Download with specific video/audio quality and create a summary file:
instarec <mpd_url> my_video.mkv --video-quality <video_id> --summary-file summary.txt
Manually Getting the MPD URL
You can manually find the manifest URL (.mpd) thourgh the browser:
- Open the Instagram livestream in a web browser.
- Open the Developer Tools (usually by pressing
F12orCtrl+Shift+I). - Go to the Network tab.
- In the filter box, type
.mpdto find the manifest request. - Right-click the request and copy the full URL.
Using Instagram Usernames (Requires additional setup)
To download using a username, you need to authenticate with Instagram. There are two methods available: cookie-based authentication and credentials-based authentication (instagrapi).
[!WARNING] Instagram is known for flagging accounts that make automated requests. Continuously polling a user's live status may get your account flagged or temporarily blocked. Use this feature at your own risk.
Cookie-Based Authentication
This method uses cookies exported from your browser and does not require instagrapi.
-
Export your Instagram cookies:
Log into Instagram in your browser, then export your cookies as a Netscape-format
.txtfile using a browser extension such as Get cookies.txt LOCALLY. -
Pass the cookie file with
--cookies:instarec --cookies cookies.txt <username> my_video.mkv
Credentials-Based Authentication (instagrapi)
-
Install
instagrapi:instagrapiis an optional dependency needed to fetch the stream URL from a username. Install it manually using pip:pip install instagrapi
-
Configure Credentials:
instarecneeds your Instagram login to check a user's live status. Create acredentials.jsonfile in the application's configuration directory with your username and password.The location of this directory depends on your operating system:
- Linux:
~/.config/instarec/credentials.json - macOS:
~/Library/Application Support/instarec/credentials.json - Windows:
C:\Users\<YourUser>\AppData\Local\instarec\instarec\credentials.json
The content of
credentials.jsonshould be:{ "username": "your_instagram_username", "password": "your_instagram_password" }
- Linux:
Command-Line Arguments
| Argument | Short | Description |
|---|---|---|
url_or_username |
The URL of the .mpd manifest, a raw Instagram username, or a raw instagram user ID. | |
output_path |
The destination filepath for the final video. Defaults to .mkv if no extension is provided. |
|
--cookies |
Path to a Netscape-format cookie file for Instagram authentication. | |
--interactive |
-i |
Interactively select video and audio quality. |
--log-file |
Path to a file to write logs to. | |
--summary-file |
Path to a file to write a download summary to. | |
--verbose |
-v |
Enable verbose (DEBUG level) logging. |
--quiet |
-q |
Suppress informational (INFO level) logging. |
--video-quality |
One or more representation IDs for video, in order of preference. | |
--audio-quality |
One or more representation IDs for audio, in order of preference. | |
--poll-interval |
Seconds to wait between polling the manifest for live segments. | |
--max-search-requests |
Maximum concurrent requests when searching for past segments. | |
--download-retries |
Number of retries for a failed segment download. | |
--download-retry-delay |
Initial delay in seconds between download retries. | |
--check-url-retries |
Number of retries for a failed URL check. | |
--proxy |
Proxy URL (e.g. http://user:pass@host:port or socks5://host:port). | |
--no-past |
Do not download past segments, start with the livestream. | |
--end-stream-miss-threshold |
Number of consecutive timestamps to search before assuming the past stream has ended. | |
--search-chunk-size |
Number of segments to check for existence in a single batch when searching. | |
--live-end-timeout |
Seconds to wait without a new live segment before assuming the stream has ended. | |
--past-segment-delay |
Minimum time in seconds between each past segment download. | |
--keep-segments |
Do not delete the temporary segments directory after finishing. | |
--ffmpeg-path |
Path to the ffmpeg executable. | |
--ffprobe-path |
Path to the ffprobe executable. |
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file instarec-1.7.1.tar.gz.
File metadata
- Download URL: instarec-1.7.1.tar.gz
- Upload date:
- Size: 34.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
55ae1692054946e89656610bf6a77b08daf3bf2681ac03e8c6050b4c23d64864
|
|
| MD5 |
d362e0af1ce08d9e363582cb69b73757
|
|
| BLAKE2b-256 |
240b1b117a9e10d24d5dff4befa46efd06d653eb1e96b4570cd1eb0fb8102efc
|
Provenance
The following attestation bundles were made for instarec-1.7.1.tar.gz:
Publisher:
publish.yml on qwer-lives/instarec
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
instarec-1.7.1.tar.gz -
Subject digest:
55ae1692054946e89656610bf6a77b08daf3bf2681ac03e8c6050b4c23d64864 - Sigstore transparency entry: 1155437369
- Sigstore integration time:
-
Permalink:
qwer-lives/instarec@b8208ea6f0fd1976acc959af56586278e0c773c1 -
Branch / Tag:
refs/tags/v1.7.1 - Owner: https://github.com/qwer-lives
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b8208ea6f0fd1976acc959af56586278e0c773c1 -
Trigger Event:
release
-
Statement type:
File details
Details for the file instarec-1.7.1-py3-none-any.whl.
File metadata
- Download URL: instarec-1.7.1-py3-none-any.whl
- Upload date:
- Size: 38.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
67ae23b214583cc1c4541da935ad1a1a2eb9a0246cb2bc45e90d0a427265c97a
|
|
| MD5 |
0bd34193dd1ab249d5f61c60c4672337
|
|
| BLAKE2b-256 |
f756cbb93c36de5807218b6fcf0453060c022703bce086f23364958dab7201fa
|
Provenance
The following attestation bundles were made for instarec-1.7.1-py3-none-any.whl:
Publisher:
publish.yml on qwer-lives/instarec
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
instarec-1.7.1-py3-none-any.whl -
Subject digest:
67ae23b214583cc1c4541da935ad1a1a2eb9a0246cb2bc45e90d0a427265c97a - Sigstore transparency entry: 1155437372
- Sigstore integration time:
-
Permalink:
qwer-lives/instarec@b8208ea6f0fd1976acc959af56586278e0c773c1 -
Branch / Tag:
refs/tags/v1.7.1 - Owner: https://github.com/qwer-lives
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b8208ea6f0fd1976acc959af56586278e0c773c1 -
Trigger Event:
release
-
Statement type: