Skip to content

feat(download): embed subtitles into the mp4 instead of a sidecar .vtt - #1991

Closed
emre-tiryaki wants to merge 2 commits into
pystardust:masterfrom
emre-tiryaki:merge-video-and-dialogue
Closed

emre-tiryaki wants to merge 2 commits into
pystardust:masterfrom
emre-tiryaki:merge-video-and-dialogue

Conversation

@emre-tiryaki

Copy link
Copy Markdown
Contributor

Pull Request Template

Type of change

  • Bug fix
  • Feature
  • Documentation update

Description

Fixes #1977

Downloads currently produce a video file plus a separate .vtt subtitle file, so the user has to keep both together and load the subtitles manually in the player.

This PR muxes the subtitles into the downloaded .mp4 as a mov_text track (default disposition, language eng), so the result is a single self-contained file.

Changes:

  • Split download(): the existing yt-dlp/ffmpeg download logic moved unchanged into fetch_media().
  • Muxing step lives in the new mux_subs() function because it was too long.
  • When embedding applies, the video is downloaded to <name>.tmp.mp4, remuxed with -c copy (no re-encoding) together with the .vtt, and the temporary files are removed on success.
  • Fallback: if there is no subtitle link, the subtitle file is empty, ffmpeg is missing, or muxing fails, the old behavior is kept (plain video, plus the .vtt next to it on mux failure). Nothing is lost in any failure path.
  • New env variable ANI_CLI_EMBED_SUBS (default 1). Set it to 0 to restore the previous sidecar .vtt behavior.

My other PR: #1975 is a seperate pr and if this or that PR merges, other one has to change. just a note

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
  • -v vlc works
  • --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

Copilot AI balanced review requested due to automatic review settings November 8, 2026 13:19

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@port19x

port19x commented Nov 9, 2026

Copy link
Copy Markdown
Collaborator

First impressions, since I don't have time for a detailed review rn.
This PR is quite large, any chance we can slim it down a little?
Why introduce an environment variable?
I don't see the value in the .vtt sidecar.
Also please inline mux_subs and fetch_media into the download function, or at least move their definition to be within it.

@emre-tiryaki

Copy link
Copy Markdown
Contributor Author

I wanted to give the user a choice to embed the subs or not, I don't know for sure but I thought maybe some people liked this behaviour. I removed it now, it only keeps the seperate file if ffmpeg is not on the system.

now the download function is embedding the subtitles with ffmpeg so if the system does not have it, the program behaves the old seperate subtitle way.

The function steps after downloading the video:

  1. checks if the subtitle file is there and ffmpeg is on the system. Does not embeds the subtitles if this condition is not met.
  2. starts embedding the subtitles into "$_out.tmp.mp4" file.
  3. if the embedding is succesfull renames the "$_out.tmp.mp4" file to "$_out"
  4. if the embedding is not successfull it just removes the tmp video and does nothing to the seperate sub file.

@port19x

port19x commented Nov 10, 2026

Copy link
Copy Markdown
Collaborator

We're moving providers again for v5.2, with early work already being under way by a contributor.
While your other PR #1975 remains valuable, this one does not and so I'm chosing to spare the effort and close this one.

@emre-tiryaki

Copy link
Copy Markdown
Contributor Author

Is this feature blocking changing the providers?

this PR removes the seperate subtitle files, why is it not important??

I'm just curious, if you want to close this PR it is you're choice.

@port19x

port19x commented Nov 10, 2026

Copy link
Copy Markdown
Collaborator

Yeah it's not too important because the next provider will have hardsubs / merged by default.
For the users, many don't care, and as such can wait until it's resolved in 5.2.
Those that can can still pull the patch from this PR.

I also suspect this doesn't affect all downloads, in which case there would have been drastically more issues / requests in discords support channel.

This PR still provides value by being a stopgap solution for the few that are affected and care enough for a patch

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.

Downloaded media no longer merged with dialogue text

3 participants