Transcode: Target MB per video, whatever its length [skip ci] #1

Open
bugzbunny wants to merge 1 commit from transcode/target-per-video into develop
Owner

Moved from GitHub: https://github.com/bugz8unny69/AniKeepOrNot/pull/332

Why

In AniKeepOrNot's Settings → Transcode, "Target MB per 24 minutes" assumed episodes are 24 minutes long, and read as "another 500 MB every 24 minutes". The owner wants one size per video.

What changes

Video length Before (500, scaled by length) After (500 per video)
12 min 250 MB 500 MB
24 min 500 MB 500 MB
48 min 1000 MB 500 MB
  • target_bytes(mb) no longer takes the duration. video_kbps spreads the whole target over the video's length, so a longer video gets a lower bitrate. Audio is still budgeted first, with 1% reserved for the container.
  • The pipeline skip check, adm transcode staged (including --dry-run estimates) and the batch skip check all use the per-video target.
  • The setting label is now Target MB per video, with help text: "Each transcoded video aims for this size, whatever its length. Videos already smaller are left unchanged."
  • docs/TRANSCODE_AGENT.md and the dashboard audit are updated.

Compatibility

The stored key transcode.target_mb and its default of 500 are unchanged, so no settings migration or schema bump is needed. An existing value now means "per video".

Trade-off

Because the size is fixed, video quality now drops as length grows. A 48-minute episode gets about half the bitrate of a 24-minute one at the same target. For a long video (a movie) with several audio tracks, the target can be too small to fit the audio at all. In that case the encode fails with the existing "Target size is too small for the audio tracks" error, and the original is kept.

Validation

  • Unit test: 24-minute video → 2494 kbps; 48-minute video → 1119 kbps; target_bytes(500) = 500,000,000 bytes, independent of length.
  • The client tests' synthetic sources now exceed the 1 MB target they configure, and their fake agents report enough free disk.
  • python -m src.anime.tests.run_batches: 41/41 batches passed. node --test src/anime/tests/dashboard_browser.test.cjs: 44 passed.

🤖 Generated with Claude Code

_Moved from GitHub: https://github.com/bugz8unny69/AniKeepOrNot/pull/332_ ## Why In AniKeepOrNot's Settings → Transcode, "Target MB per 24 minutes" assumed episodes are 24 minutes long, and read as "another 500 MB every 24 minutes". The owner wants one size per video. ## What changes | Video length | Before (500, scaled by length) | After (500 per video) | |---|---|---| | 12 min | 250 MB | 500 MB | | 24 min | 500 MB | 500 MB | | 48 min | 1000 MB | 500 MB | - `target_bytes(mb)` no longer takes the duration. `video_kbps` spreads the whole target over the video's length, so a longer video gets a lower bitrate. Audio is still budgeted first, with 1% reserved for the container. - The pipeline skip check, `adm transcode staged` (including `--dry-run` estimates) and the batch skip check all use the per-video target. - The setting label is now **Target MB per video**, with help text: "Each transcoded video aims for this size, whatever its length. Videos already smaller are left unchanged." - `docs/TRANSCODE_AGENT.md` and the dashboard audit are updated. ## Compatibility The stored key `transcode.target_mb` and its default of 500 are unchanged, so no settings migration or schema bump is needed. An existing value now means "per video". ## Trade-off Because the size is fixed, video quality now drops as length grows. A 48-minute episode gets about half the bitrate of a 24-minute one at the same target. For a long video (a movie) with several audio tracks, the target can be too small to fit the audio at all. In that case the encode fails with the existing "Target size is too small for the audio tracks" error, and the original is kept. ## Validation - Unit test: 24-minute video → 2494 kbps; 48-minute video → 1119 kbps; `target_bytes(500)` = 500,000,000 bytes, independent of length. - The client tests' synthetic sources now exceed the 1 MB target they configure, and their fake agents report enough free disk. - `python -m src.anime.tests.run_batches`: 41/41 batches passed. `node --test src/anime/tests/dashboard_browser.test.cjs`: 44 passed. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
"Target MB per 24 minutes" read as "another 500 MB every 24 minutes" and
assumed episodes are 24 minutes long. The setting is now "Target MB per
video": every transcoded video aims for that size whatever its length, and
the bitrate is that size spread over the video's duration.

The stored key (transcode.target_mb) and its default (500) are unchanged,
so no settings migration is needed; the existing value is reinterpreted.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This pull request has changes conflicting with the target branch.
  • docs/TRANSCODE_AGENT.md
  • src/anime/tests/test_transcode_client.py
  • src/anime/transcode_batch.py
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'transcode/target-per-video:transcode/target-per-video'
git switch 'transcode/target-per-video'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'develop'
git merge --no-ff 'transcode/target-per-video'
git switch 'transcode/target-per-video'
git rebase 'develop'
git switch 'develop'
git merge --ff-only 'transcode/target-per-video'
git switch 'transcode/target-per-video'
git rebase 'develop'
git switch 'develop'
git merge --no-ff 'transcode/target-per-video'
git switch 'develop'
git merge --squash 'transcode/target-per-video'
git switch 'develop'
git merge --ff-only 'transcode/target-per-video'
git switch 'develop'
git merge 'transcode/target-per-video'
git push origin 'develop'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
bugzbunnynet/AniKeepOrNot!1
No description provided.