wrolpi/app/src
lrnselfreliance 0b61d3ab08
Some checks failed
CodeQL / Analyze (push) Has been cancelled
Controller Tests / controller-tests (push) Has been cancelled
Jest Tests / jest-tests (push) Has been cancelled
videos: codec download preferences with transcode and strict-fail options (#701)
* videos: codec download preferences with transcode and strict-fail options

Add video_codecs/audio_codecs ordered preference lists to the video,
channel, and RSS downloaders, alongside the existing resolution
selector.  Codec preference is codec-major: a preferred codec at a
lower resolution beats another codec at a higher resolution.

When 'transcode' is enabled, a downloaded file whose streams do not
match the preferences is re-encoded with ffmpeg after download (only
the mismatching stream; targets are extensible maps, currently h264
and aac/opus/mp3).  When 'strict_codecs' is enabled and transcode is
not, a download with no matching format fails permanently instead of
falling back.

Empty codec lists produce a byte-identical yt-dlp command to before.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* videos: honor strict_codecs when transcode cannot produce the preference

Review fixes:
- strict_codecs is now suppressed only when transcoding can produce a
  preferred codec for every non-empty preference list (new
  transcode_can_satisfy_codecs); av1-only preferences with transcode
  enabled fail under strict instead of silently keeping the file.
- No partial transcode: an unfixable video mismatch blocks an
  audio-only conversion (and vice versa); the mismatch falls through
  to strict/keep.
- fsync the transcode output before rename, and the directory after,
  so power loss on a Pi cannot leave a truncated final file.
- mp3 yt-dlp pattern matches mp4a.6B as well as mp4a.6b.
- ffmpeg maps use 0:V:0 (excludes attached pictures) and 0🅰️0?
  (tolerates missing audio).
- Strict toggle is no longer disabled by transcode in the UI; popup
  wording corrected.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* videos: serialize transcodes machine-wide via shared_ctx lock

Sanic runs multiple worker processes, so an asyncio primitive cannot
serialize transcodes across download workers.  A multiprocessing.Lock
in shared_ctx now guarantees only one ffmpeg transcode runs at a time
on the machine; waiting workers poll the lock asynchronously so the
event loop stays responsive while a transcode holds it for hours.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* videos: transcode-lock review fixes

- Document that a crashed lock holder requires an API restart; this is
  accepted rather than adding owner-death recovery.
- Move the 'Transcoding' user notification to after the lock is
  acquired, so it fires when work begins rather than before a
  potentially hours-long wait.
- Soften the lock test docstring to what it measures (in-process
  wait/release); trim the acquire docstring to the polling rationale.
- Give transcode_lock its own section header in contexts.py.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-09-07 09:12:00 -06:00
..
api controller: VNC toggle, gated on the Desktop running 2026-07-29 18:10:05 -06:00
components videos: codec download preferences with transcode and strict-fail options (#701) 2026-09-07 09:12:00 -06:00
contexts ui: the last of Semantic UI, in name and in dead CSS 2026-08-08 18:05:54 -06:00
hooks Fix API stalls: non-blocking switch worker, threaded searches, indexed Videos page (#678) 2026-08-29 16:17:53 -06:00
themes review: the color-scheme half of this was already there 2026-08-08 18:05:54 -06:00
types ui: the last Semantic UI file, and the stylesheet with it 2026-08-08 18:04:03 -06:00
api.js Fix API stalls: non-blocking switch worker, threaded searches, indexed Videos page (#678) 2026-08-29 16:17:53 -06:00
App.css files: left-align the preview toolbar (#698) 2026-09-03 16:03:17 -06:00
App.js ui: the last Semantic UI file, and the stylesheet with it 2026-08-08 18:04:03 -06:00
babel-pins.test.js build: put the @babel pins back, and make them fail loudly if dropped again (#653) 2026-08-08 18:54:34 -06:00
DashboardPage.js ui: two upload dialogs that had drifted apart (#664) 2026-08-13 15:15:04 -06:00
DashboardPage.test.js ui: the dashboard's status panel links without looking like a link 2026-08-08 18:05:54 -06:00
Events.js ui: thirty-five files off Semantic, leaving fifteen 2026-08-08 18:04:01 -06:00
import-cycles.test.js fix: break the import cycle that put useCalculators in the TDZ 2026-08-08 18:05:47 -06:00
index.css ui: the last Semantic UI file, and the stylesheet with it 2026-08-08 18:04:03 -06:00
index.js Fixing changes before merge. 2023-02-08 21:18:51 -07:00
logo.svg Renaming examples to avoid grouping of pdf with ebooks. Reworking URLs for media files to avoid escaping url safe characters. 2023-03-29 13:46:39 -06:00
no-semantic-ui.test.js ui: the last of Semantic UI, in name and in dead CSS 2026-08-08 18:05:54 -06:00
reportWebVitals.js Renaming examples to avoid grouping of pdf with ebooks. Reworking URLs for media files to avoid escaping url safe characters. 2023-03-29 13:46:39 -06:00
setupTests.js ui: the last of Semantic UI, in name and in dead CSS 2026-08-08 18:05:54 -06:00
Tags.cy.js test: the component suite's twelve failures, none of them about the component 2026-08-08 18:05:54 -06:00
Tags.js files: left-align the preview toolbar (#698) 2026-09-03 16:03:17 -06:00
Tags.test.js ui: the last of Semantic UI, in name and in dead CSS 2026-08-08 18:05:54 -06:00
test-fixtures.js ui: the last of Semantic UI, in name and in dead CSS 2026-08-08 18:05:54 -06:00
test-fixtures.test.js ui: the last of Semantic UI, in name and in dead CSS 2026-08-08 18:05:54 -06:00
test-utils.js style: spell it "color" everywhere 2026-08-08 18:05:50 -06:00
test-utils.test.js style: spell it "color" everywhere 2026-08-08 18:05:50 -06:00