Skip to content

fix: play separate HLS audio tracks - #1967

Merged
port19x merged 1 commit into
pystardust:masterfrom
U-L-M-S:fix/hls-separate-audio
Oct 22, 2026
Merged

port19x merged 1 commit into
pystardust:masterfrom
U-L-M-S:fix/hls-separate-audio

Conversation

@U-L-M-S

@U-L-M-S U-L-M-S commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

Type of change

  • Bug fix

Description

Fixes #1960.

Some titles ship their audio as separate EXT-X-MEDIA renditions in the master playlist (Overgeared ep 2 from the issue, The Laid-Off Cheat-Granting Mage on the sub and the dub server). The parser dropped those lines, so the selected quality was a video-only playlist and mpv played in silence. Titles with muxed audio were never affected, which is why it looked random.

hianime_m3u8 now keeps the DEFAULT=YES audio rendition (Japanese on sub, English on dub) in audio_link and the players get it next to the subtitles: --audio-file for mpv, flatpak mpv and syncplay, --mpv-audio-files for IINA, :input-slave for VLC, audio-file= in the Android mpv include. Downloads of these titles go through ffmpeg with the audio as second input, yt-dlp cannot merge an external playlist. Nothing changes for muxed titles. catt, iSH and VLC on Android take no second input and still get the video-only variant.

Related: #1962 (subtitle lang is always en) is a separate bug in the same provider path. #1909 was sudo + pipewire, #1964 is the other way round (video missing). None of those is touched here.

Tested on Windows with mpv: the reported anime plays with sound in sub and dub, -d -q 360p gives an mp4 with h264 and Japanese AAC over the full 23:40, One Piece (muxed audio) behaves as before. VLC, IINA, syncplay and Android follow the documented options, not tested here.

Checklist

  • any anime playing
  • bumped version

  • next, prev, replay and select work
  • -c history and continue work
  • -d downloads work
  • -e (select episode) aka -r (range selection) works
  • -S select index works
  • -q quality works
  • -s syncplay works (not installed)
  • -v vlc works (not installed)
  • --dub and regular (sub) mode both work
  • --nextep-countdown countdown to next ep works

  • -h help info is up to date
  • Readme is up to date
  • Man page is up to date

Additional Testcases

  • --skip ani-skip works
  • --no-detach no detach works
  • --exit-after-play auto exit after playing works

Some hianime titles ship audio as separate EXT-X-MEDIA renditions, so the
selected quality variant was video only and played silently.

- Pick the DEFAULT=YES audio rendition from the master playlist
- Pass it as external audio to mpv, IINA, VLC and syncplay
- Mux it into downloads with ffmpeg instead of yt-dlp
- Bump version to 5.1.6

Fixes pystardust#1960
Comment thread ani-cli
command -v "yt-dlp" >/dev/null && yt-dlp --referer "$refr" "$1" --no-skip-unavailable-fragments --fragment-retries infinite -N 16 -o "$download_dir/$_name.mp4" $3 && return 0
ffmpeg -extension_picky 0 -referer "$refr" -loglevel error -stats -i "$1" -c copy "$download_dir/$_name.mp4" $3
[ -z "$audio_link" ] && command -v "yt-dlp" >/dev/null && yt-dlp --referer "$refr" "$1" --no-skip-unavailable-fragments --fragment-retries infinite -N 16 -o "$download_dir/$_name.mp4" $3 && return 0
ffmpeg -extension_picky 0 -referer "$refr" -loglevel error -stats -i "$1" ${audio_link:+-extension_picky 0 -referer "$refr" -i "$audio_link"} -c copy "$download_dir/$_name.mp4" $3

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-extension_picky 0 is not recognized by the FFmpeg 7.1 Windows build, so downloads fail with “Unrecognized option”. Could this flag be removed or used only when supported? The separate audio muxing works without it, preserving compatibility with older FFmpeg versions.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The flag is older than this PR, master added it in #1545 because the host serves .ts.jpg segments and ffmpeg 7.1.1 and newer reject them without it (checked n7.1.1, n7.1.2 and n8.0, all have the option and the check on by default).

Only the original 7.1 build lacks it, a 7.1.x update fixes that. Making it conditional would be a separate change.

@U-L-M-S
U-L-M-S requested a review from rvoroz October 16, 2026 21:19
@port19x

port19x commented Oct 20, 2026

Copy link
Copy Markdown
Collaborator

I'll treat Overgeared ep 2 as my test case. Code looks good

@rorozco-rynoh rorozco-rynoh left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good tested with Nina Liston Merciless Maiden

@rorozco-rynoh

Copy link
Copy Markdown

Also I have the fix applied in my local script and its working

@U-L-M-S

U-L-M-S commented Oct 21, 2026

Copy link
Copy Markdown
Contributor Author

If you want the fix before it is merged, you only need the one script file from the PR branch. Dependencies are the same as master.

Linux, macOS, Termux

curl -LO https://raw.githubusercontent.com/U-L-M-S/ani-cli/fix/hls-separate-audio/ani-cli
chmod +x ani-cli
./ani-cli "laid-off cheat-granting mage"

Or with git:

git clone -b fix/hls-separate-audio https://github.com/U-L-M-S/ani-cli.git
cd ani-cli
./ani-cli "laid-off cheat-granting mage"

If you already have a clone of this repo: git fetch origin pull/1967/head:pr-1967 && git checkout pr-1967

Windows

Same commands in Git Bash. From PowerShell bash is usually WSL, so call Git's bash directly:

& "C:\Program Files\Git\bin\bash.exe" .\ani-cli "laid-off cheat-granting mage"

Scoop users can copy the file over ~\scoop\apps\ani-cli\current\ani-cli. scoop update puts the old one back.

Check and play

./ani-cli -V prints 5.1.6. ANI_CLI_PLAYER=debug ./ani-cli -S 1 -e 2 overgeared prints an Audio: line with the audio playlist when a title is affected. Then as usual:

./ani-cli -S 1 -e 2 overgeared          # play, sub
./ani-cli --dub -S 1 -e 2 overgeared    # play, dub
./ani-cli -d -S 1 -e 2 overgeared       # download, needs ffmpeg 7.1.1 or newer

Do not run -U on this copy, it replaces the script with master again.

Notes on the choices:

  • One file instead of a full clone is the easiest path on every platform, since ani-cli is a single script. The git variants are there for people who prefer them.
  • The PowerShell line covers the trap you hit yourself: bash resolving to WSL.
  • The ffmpeg note matches your answer in the review thread, because downloads of affected titles go through ffmpeg.

@port19x

port19x commented Oct 22, 2026

Copy link
Copy Markdown
Collaborator
Screenshot 2026-10-22 at 18 13 38

Can confirm the issue and fix

@port19x
port19x merged commit 0301d67 into pystardust:master Oct 22, 2026
8 checks passed
ReynkeDeVos added a commit to ReynkeDeVos/ani-hop that referenced this pull request Oct 23, 2026
…, release 0.6.5 (#13)

- shows whose audio is a separate track (Cyberpunk: Edgerunners 2)
  downloaded without sound with ani-cli 5.1; with an ani-cli that has
  pystardust/ani-cli#1967 they download through ffmpeg, which a
  stand-in ffmpeg makes write a .part file, renamed only when ffmpeg
  finished without skipped segments, dropped connections or errors,
  and report how far it got; a video-only download is deleted and
  reported as having no sound
- one "Downloads…" per show instead of "Download episodes…" and
  "Delete downloads…": every episode with its state (not downloaded,
  queued, downloading with progress, on disk with its size, queued in
  another ani-hop); enter downloads, stops or deletes after asking, and
  marked episodes in different states ask which
- downloads can be stopped: the episode leaves the queue, the running
  one is killed and its partial files deleted
- the queue lives in memory, written through to its file; the worker
  re-reads it before each episode, and what's on disk or queued is
  never downloaded again
- the footer's download line ends in "…" before the key hints
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Separate HLS audio tracks are lost during quality selection (Overgeared episode 2)

4 participants