Metadata-Version: 2.4
Name: yt-dlp-instagram-hdr
Version: 0.7.0
Summary: yt-dlp plugin for downloading HDR Instagram videos, Reels, IGTV, and Stories
Home-page: https://github.com/viniciusron7/yt-dlp-instagram-hdr
License: MIT
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: yt-dlp>=2026.8.19
Dynamic: license-file

# yt-dlp Instagram HDR

A [yt-dlp](https://github.com/yt-dlp/yt-dlp) plugin that adds HDR formats for Instagram Reels, Stories, IGTV, and video posts.

Supports VP9 Profile 2 and AV1 10-bit HDR. By default, the plugin starts with
Instagram's web API and checks the iOS API when a successful web response lacks
HDR or separate audio. It combines HDR, SDR, progressive video and audio formats
for the same media item, so no extra extractor arguments are needed for HDR
discovery or `bv+ba`. The same CDN object is listed once even when it arrives
from both APIs, from different edge hosts or under several `video_versions`
entries.
xHE-AAC is excluded unless explicitly enabled, or unless it is the only
audio-only format available; a progressive video never replaces a separate audio
track.
Video and audio are merged without re-encoding (unless the `hevc` option is enabled)
and the HDR video is verified with `ffprobe`.

## Requirements

- Python 3.11+ for current yt-dlp (yt-dlp dropped Python 3.10 in 2026.11.23).
  The plugin itself still runs on Python 3.10, where pip installs the newest
  yt-dlp that supports it, 2026.10.21
- yt-dlp 2026.08.19+ (tested up to 2026.11.23)
- FFmpeg and `ffprobe` on your PATH (the executables, not the Python `ffmpeg` package)
- Authenticated Instagram cookies for the plugin's API extraction

Optional HEVC conversion requires an FFmpeg build with `hevc_videotoolbox`
(macOS) or `libx265`. No conversion is performed unless you enable it.

## Installation

If you know how yt-dlp was installed, jump to [pip](#pip), [pipx](#pipx), or
[manual installation](#manual) (Homebrew and standalone executables).
Otherwise, identify the installation with the commands below; unavailable
commands can be skipped.

**macOS**

```shell
command -v yt-dlp
pipx list
python3 -m pip show yt-dlp
brew list --versions yt-dlp
```

**Linux**

```shell
command -v yt-dlp
pipx list
python3 -m pip show yt-dlp
```

**Windows (PowerShell)**

```powershell
Get-Command yt-dlp
pipx list
py -m pip show yt-dlp
```

Use the result that matches your output:

| Output                                                       | Installation type |
| ------------------------------------------------------------ | ----------------- |
| `package yt-dlp ...` in `pipx list`                          | [pipx](#pipx)     |
| `Name: yt-dlp` from `pip show`                               | [pip](#pip)       |
| `yt-dlp <version>` from `brew list`                          | [manual](#manual) |
| yt-dlp has a path, but the checks above report it as missing | [manual](#manual) |

`Package(s) not found`, `nothing has been installed with pipx`, and `No such keg`
are negative results; continue to the next check. If `command -v` or `Get-Command`
cannot find yt-dlp, install yt-dlp first.

If more than one check finds yt-dlp, use the manual method to avoid installing the
plugin into the wrong Python environment.

### pip

Run these commands in the same Python environment as yt-dlp.

macOS/Linux:

```shell
python3 -m pip install -U yt-dlp-instagram-hdr
```

Windows:

```powershell
py -m pip install -U yt-dlp-instagram-hdr
```

### pipx

```shell
pipx inject yt-dlp yt-dlp-instagram-hdr --force
```

### Manual

Download the latest `.whl` from [Releases](https://github.com/viniciusron7/yt-dlp-instagram-hdr/releases/latest), and place it, without extracting it, in:

- macOS/Linux: `$XDG_CONFIG_HOME/yt-dlp/plugins/`, or `~/.config/yt-dlp/plugins/` when it is not set
- Windows: `%APPDATA%/yt-dlp/plugins/`

Create the folder if necessary. Keep only one version of this plugin there;
when updating, replace the old `yt_dlp_instagram_hdr-*.whl` with the new wheel.
See yt-dlp's [plugin installation documentation](https://github.com/yt-dlp/yt-dlp#installing-plugins)
for other supported locations.

### Updating

For pip, repeat the installation command with `-U`. For pipx:

```shell
pipx upgrade yt-dlp --include-injected
```

For manual installations, replace the wheel as described above. Updating
yt-dlp itself does not update a manually installed plugin.

## Usage

Authenticated downloading can expose the account to challenges, session
invalidation or suspension. A yt-dlp maintainer explicitly documents this
[risk of flagged or banned accounts](https://github.com/yt-dlp/yt-dlp/issues/17074).
The plugin cannot guarantee that an account will not be suspended, and cannot
determine which browser account is your main account. Avoid supplying a session
for an account you cannot afford to lose. A separate browser profile using the
same account still exposes that account.

For public content, you can first try without authenticated cookies:

```shell
yt-dlp "VIDEO_URL"
```

This uses yt-dlp's built-in extractor; available formats and anonymous access
depend on Instagram. For authenticated extraction, choose the browser/profile
deliberately and log in there first. Replace `VIDEO_URL` with a Reel
(`/reel/`, `/reels/`), post (`/p/`), IGTV (`/tv/`, which is also where
`instagram://media?id=` resolves) or Story (`/stories/`) URL, keeping the
quotes. `instagram.com/share/...` links are not supported by yt-dlp; open one in
a browser and use the canonical URL it lands on. A link to one slide of a
carousel carries `?img_index=N`; with `--no-playlist` that slide alone is
downloaded, and without it the whole post is, as yt-dlp does elsewhere.
`--cookies-from-browser chrome` is still supported;
to select a Chrome profile explicitly, use `--cookies-from-browser
"chrome:PROFILE_DIRECTORY"`, replacing `PROFILE_DIRECTORY` with that profile's
directory name or path (shown at `chrome://version`). Replace `chrome` with your
supported browser name if needed. Cookies are credentials, not a protection
against account restrictions.

**Default: download HDR when available, without converting the video codec.**

```shell
yt-dlp --cookies-from-browser chrome "VIDEO_URL"
```

yt-dlp selects the best available formats and merges video/audio when needed.
Merging is not re-encoding: an `.mp4` can still contain VP9 or AV1 video.
The `HDR verified` message is a read-only metadata check, not a conversion; if the
check fails, a warning is printed and the download is kept. It also runs when the
HEVC conversion was enabled but skipped, so the file that is actually produced is
always the one that gets checked.

Apple's players (QuickTime, Photos, iPhone and iPad) cannot play VP9 in MP4, which
is how Instagram delivers HDR. For files that play and save on Apple devices,
enable the [optional HEVC conversion](#optional-hevc-conversion).

List available formats with `-F`:

```shell
yt-dlp -F --cookies-from-browser chrome "VIDEO_URL"
```

Plugin HDR formats have IDs starting with `hdr-`. Their `dynamic_range` is `HLG`
or `HDR10` when the manifest states the transfer characteristic, and a bare `HDR`
for a 10-bit BT.2020 rendition whose transfer it does not state. yt-dlp only
understands `SDR`/`HDR10`/`HDR10+`/`HDR12`/`HLG`/`DV`, so for that bare value it
leaves the `-F` HDR column empty and `-S hdr` ranks it below `HLG`. Select with
`-f "bv*[dynamic_range!=SDR]+ba/b"` rather than `[dynamic_range=HLG]`, which
would miss those renditions; the format ID and `format_note` still say `hdr`. To explicitly select separate
video and audio streams:

```shell
yt-dlp -f "bv+ba" --cookies-from-browser chrome "VIDEO_URL"
```

The automatic API selection preserves compatible audio from the web response
when HDR comes from iOS. For silent videos, use the default selection instead,
since an audio-only stream may not exist.

You can also use a cookie file:

```shell
yt-dlp --cookies cookies.txt "VIDEO_URL"
```

The cookie file must use the Netscape format supported by yt-dlp. Treat it as a
password: do not share it or commit it to a repository.

Without authenticated cookies, the plugin shows a warning and delegates to
yt-dlp's built-in Instagram extractor. With authentication, media without HDR
keeps the available SDR and audio formats from the same response.

### Account access and request limits

The default `api=auto` starts with the web application ID and yt-dlp's browser
headers. After a successful response without HDR or separate audio, it makes one
additional media request using the iOS application ID and user agent, then
combines formats by media ID. This uses a mobile application identity with
browser cookies and carries the account risk described above. Use `instagramhdr:api=web` to restrict
extraction to the web API. Neither mode fabricates device IDs or random telemetry.
Changing headers cannot make authenticated automation indistinguishable from
normal browsing.

yt-dlp's own `instagram:app_id` is honoured when `instagramhdr:api` is unset:
`web`, `ios` or either of those two application IDs selects the matching mode, so
the application ID, host, user agent and impersonation setting stay consistent.
`instagramhdr:api` takes precedence when both are given, and any other
application ID prints a warning and uses the web API.

Metadata requests made by this plugin are spaced by two seconds by default,
shared between Reels and Stories in the same yt-dlp run. Use yt-dlp's
`--sleep-requests SECONDS` to set an explicit interval. This limits request bursts;
it is not an Instagram-approved rate or a guarantee against suspension. Avoid
running multiple download processes with the same session.

HTTP 401/403/404/429, login/verification redirects and recognized challenge or
restriction JSON responses stop further metadata requests through this plugin
for the current run, including with `--ignore-errors`. There is no automatic
authenticated fallback after these errors. A 404 can indicate unavailable media
or a session restriction, so it also stops the run's plugin requests. Check the
account in Instagram and resolve restrictions before trying again; repeatedly
refreshing cookies is not a fix for account limits. The stop flag is local to
that yt-dlp process, not a persistent or cross-process account lock. Extractors
outside this plugin, including the explicitly disabled mode, retain yt-dlp's own
behavior.

Stories preserve the tray's available audio and video formats. When the tray
omits HDR, the plugin requests media details (a tray's SDR manifest can omit
available HDR). Automatic mode also checks iOS when HDR or separate audio is
still missing. With a specific Story URL and `--no-playlist`, other Stories are
not queried for media details.

Instagram can return different formats for web and mobile clients. Automatic
mode handles this without extra arguments. To start directly with the iOS API:

```shell
yt-dlp --cookies-from-browser "chrome:PROFILE_DIRECTORY" --extractor-args "instagramhdr:api=ios" "VIDEO_URL"
```

This option prints a warning and also checks the web API when the iOS response
lacks compatible separate audio, unless `include_xhe_aac` is enabled and xHE-AAC
audio is available. All modes retain the request interval and stop protections;
an access rejection never triggers a request with another client. They preserve
the available VP9/AV1 HDR downloads, optional HEVC conversion, Stories and the
audio options below. Availability still depends on the API responses; the plugin
cannot force Instagram to expose an HDR rendition.

### Plugin options

Disable the HDR plugin and force yt-dlp's built-in Instagram extractor:

```shell
yt-dlp --cookies-from-browser chrome --extractor-args "instagramhdr:disable" "VIDEO_URL"
```

Include xHE-AAC (`mp4a.40.42`) audio alongside the other audio formats:

```shell
yt-dlp --cookies-from-browser chrome --extractor-args "instagramhdr:include_xhe_aac" -F "VIDEO_URL"
```

Remove `-F` to download. Enabling this option can make yt-dlp select xHE-AAC,
which some players do not support. Leave it off for better compatibility.

Photos are offered as a single `image` format: the largest still Instagram
returns for that item. This applies to photo posts, to the photo items of a
mixed carousel (which otherwise failed the whole post with
`No video formats found!`) and to photo Stories (which were skipped silently).
Since that file already is the largest still, such an item lists no separate
thumbnails, so `--write-thumbnail` writes nothing extra for it and
`--embed-thumbnail` skips it instead of failing on a JPEG. Video items are
unaffected. To list only the videos again:

```shell
yt-dlp --cookies-from-browser chrome --extractor-args "instagramhdr:images=false" "VIDEO_URL"
```

With `images=false` a photo-only item has no formats, so yt-dlp reports an error
for it; add `-i` to skip such items in a carousel or Story.

### Optional HEVC conversion

HEVC conversion is **disabled by default**: without `instagramhdr:hevc`, the
original video codec is preserved. Merging video/audio and verifying HDR metadata
do not re-encode the video.

For better compatibility with HEVC-capable Apple devices and other players,
explicitly enable conversion of HDR downloads to HEVC Main 10 (`hvc1`). The result
is an `.mp4` whatever `--merge-output-format` says; `--remux-video` can still change
its container afterwards. `--recode-video` would re-encode it again, so with it the
conversion is skipped with a warning; likewise with `-x`. This is a lossy
re-encode and takes additional time; it preserves and checks the HDR colour tags,
but is not a lossless copy. VideoToolbox is used when your FFmpeg has it, with
`libx265` as a slower software fallback. Audio, subtitles and cover art are copied:

```shell
yt-dlp --cookies-from-browser chrome --extractor-args "instagramhdr:hevc" "VIDEO_URL"
```

The HEVC file is usually larger than the download (about 1.3–3× in tests). For
smaller files at lower quality, pass encoder options; they are applied after the
plugin's defaults. `-q:v` sets the VideoToolbox quality (default 50, higher is
better) and `-crf` the `libx265` quality (default 22, lower is better):

```shell
yt-dlp --cookies-from-browser chrome --extractor-args "instagramhdr:hevc" --ppa "InstagramHDRHEVC:-q:v 40 -crf 26" "VIDEO_URL"
```

`--ppa` adds options to whichever encoder runs, but it cannot choose one.
`instagramhdr:hevc_encoder` does: `auto` (the default: VideoToolbox first, then
`libx265`), `videotoolbox`, or `x265`. Only the named encoder is attempted, so
the conversion fails instead of falling back if it is missing or its output does
not verify. On Apple silicon `libx265` reaches comparable quality at a smaller
size than VideoToolbox, at a much slower speed:

```shell
yt-dlp --cookies-from-browser chrome --extractor-args "instagramhdr:hevc;hevc_encoder=x265" "VIDEO_URL"
```

When the conversion cannot run — no usable HEVC encoder, no `ffprobe`, a file in
the way, or an encode that fails — a warning says why and the HDR download is
kept as it is, with its `--download-archive` entry. The output must also carry
the `hvc1` codec tag that Apple players require: if extra `--ppa` options
override it, the conversion is refused rather than reported as verified.

After a successful conversion the original is deleted, like with
`--recode-video`, unless:

- `-k` is used: the original is kept (as `*.orig.mp4` when it was already an MP4),
  together with the separately downloaded video/audio streams (`*.f<format>.*`);
- `--no-overwrites` is used and the original was not downloaded by this run (for
  example a file that yt-dlp reports as already downloaded): it is kept too (as
  `*.orig.mp4` when it was already an MP4).

Running the same command again skips files that are already converted: like
`--remux-video`, an existing `<name>.mp4` (or the container chosen with
`--remux-video`) counts as the finished result. If that
file is an earlier download that is not HDR, a warning says so and it is kept;
pass `--force-overwrites` to download it again. An existing file at the HEVC
destination, or an existing `*.orig.mp4` that would be kept, also stops the
conversion unless `--force-overwrites` is given.

The option only affects HDR video selections; it does not turn SDR into HDR, and
it is skipped (with a warning) when several video streams are merged with
`--video-multistreams`. If your `-f`/`-S` options pick an SDR format although HDR
formats exist, a warning says so before the download. Audio-only downloads,
including `-x`, skip HDR conversion and verification. The option does not convert
xHE-AAC audio, so enabling both options can still produce audio that your player
cannot play.

### Other controls

`view_count` is filled from Instagram's play count when the API does not report
views, which is the usual case for Reels and Stories.

These `instagramhdr` options apply to Reels, posts, IGTV, and Stories. Boolean
options accept `1`/`true`/`yes`/`on` and `0`/`false`/`no`/`off`, or no value at
all (which means true); any other value is an error rather than a silent `true`,
and an unknown option name or namespace prints a warning naming it. To combine
options, separate them with semicolons inside the same quoted argument:

```shell
yt-dlp --cookies-from-browser chrome --extractor-args "instagramhdr:hevc;include_xhe_aac" "VIDEO_URL"
```

Use the `instagramhdrstory` key to override an option for Stories only.
Advanced: `instagramhdr:verify=false` disables the default read-only HDR check;
HEVC conversion still verifies its input and output.

The options are stored in the info JSON when the video is extracted. When
downloading from `--load-info-json`, no extraction runs, so add the plugin's
post-processors yourself:

```shell
yt-dlp --load-info-json FILE --use-postprocessor "InstagramHDRSelection:when=video" --use-postprocessor InstagramHDRHEVC --use-postprocessor "InstagramHDRVerify:when=after_move"
```

## Troubleshooting

- **No HDR formats:** check that the selected browser/profile is logged in and
  that the upload has HDR. Available SDR/audio formats are kept. Web and iOS can
  expose different formats; see the explicit iOS option and its account risk above.
- **HTTP 401/403/404/429 or account verification:** the plugin stops its metadata
  requests for that run. Check the account and content directly in Instagram;
  resolve challenges and allow limits to clear before another attempt. Neither
  switching clients nor disabling the plugin bypasses Instagram's restrictions.
- **Missing FFmpeg/ffprobe or HEVC encoder:** install the executables, check
  `ffmpeg -version` and `ffprobe -version`, or set `--ffmpeg-location "PATH"`.
  `ffmpeg -hide_banner -encoders` must list `hevc_videotoolbox` or `libx265`.
- **SDR downloaded although HDR formats are listed:** check `-f`/`-S` in your
  command and configuration; `-f "bv*[dynamic_range!=SDR]+ba/b"` prefers HDR.
- **Unexpected conversion:** check your yt-dlp configuration for `hevc` or other
  conversion options. Use `--ignore-config` to test without saved settings.
- **Old plugin still loaded:** remove duplicate copies of this plugin and check
  the plugin paths in `yt-dlp --verbose -F --cookies-from-browser chrome "VIDEO_URL"`.
  A manually installed wheel may take precedence over a pip installation.

`yt-dlp --verbose` prints the plugin version, and a yt-dlp older than this
plugin supports prints a warning instead of failing in confusing ways.

When reporting a problem, include the yt-dlp/plugin versions and the command
used. Redact cookies, credentials, private URLs and other personal data from logs.

## Testing a checkout

Run from the repository root with a Python environment containing yt-dlp:

```shell
python -m unittest discover -s tests -v
yt-dlp --ignore-config --no-plugin-dirs --plugin-dirs .. --cookies-from-browser chrome -F "VIDEO_URL"
```

The tests use the local source, not an installed wheel. The second command also
loads this checkout; add `--extractor-args "instagramhdr:hevc"` and remove `-F`
only when you want to test conversion. The automated tests do not contact Instagram.

## License

[MIT](LICENSE) © 2026 Vinicius Roncetti
