- Reencodarr is an Elixir/Phoenix app for bulk AV1 transcoding with
ab-av1. - It syncs media from Sonarr/Radarr, analyzes files, runs CRF search, encodes, and updates the live dashboard.
- Prefer short, durable instructions over architecture essays.
- Remove stale notes instead of preserving history here.
- Prefer repo evidence, logs, diagnostics, and tests over guessing.
- Use
nix develop -c <command>for repo commands. nix develop -c mix setupinstalls deps, creates/migrates the DB, and builds assets.nix develop -c mix testruns the full test suite. Prefer the full suite before finishing when practical.nix develop -c mix compile --warnings-as-errorscatches compile regressions.nix develop -c mix credo --strictis the lint pass.nix develop -c mix formatandnix develop -c mix format --check-formattedhandle formatting.
- Prefer
bin/rpcfor inspecting the running system; do not guess. - Useful commands:
bin/rpc 'Reencodarr.Diagnostics.status()'bin/rpc 'Reencodarr.Diagnostics.video(123)'bin/rpc 'Reencodarr.Diagnostics.find("name")'bin/rpc 'Reencodarr.Diagnostics.failures()'bin/rpc 'Reencodarr.Diagnostics.queues()'bin/rpc 'Reencodarr.Diagnostics.processes()'bin/rpc 'Reencodarr.Diagnostics.stuck()'bin/rpc 'Reencodarr.Diagnostics.video_args(123)'
- Failures include
system_context; read it before changing code.
- Database is SQLite. Keep SQLite tuning centralized in
config/config.exs. - Broadway pipelines exist for analyzer, CRF searcher, and encoder.
- Producers should check worker availability before dispatching work.
- Test disables Broadway-based workers/supervisors that interfere with sandboxed tests.
- Video states are
:needs_analysis,:analyzing,:analyzed,:crf_searching,:crf_searched,:encoding,:encoded, and:failed. - Use
VideoStateMachinehelpers for transitions when one exists. - Treat
:encodedas protected during sync. Sync must not reset encoded state or discard chosen VMAF/original-size data. - If sync metadata changes invalidate CRF results, only reset videos that are not already encoded.
- Sonarr/Radarr sync should avoid unnecessary DB work, but must still detect replaced files.
service_idon videos represents the source file identifier and is useful for change detection.- Do not rely only on parent item timestamps; replacements can happen without the parent item looking new.
Reencodarr.AbAv1.OutputParseris the shared parser forab-av1output.- Keep encode and CRF-search parsing aligned through shared parser logic.
Reencodarr.Rules.build_args/4is the central encode/CRF-search argument builder.
- Service clients live under
lib/reencodarr/services/. - Follow the existing
CarReqpattern with retries and fuse/circuit-breaker behavior. - Config records use
service_type,url,api_key,enabled, andlast_synced_at.
- Prefer existing fixtures/helpers in
test/support/fixtures.ex. - Use
meckwhere the current test suite already uses it for external command mocking. - When changing sync, parser, state-machine, or LiveView behavior, add or update tests near the affected module.
lib/reencodarr/sync.ex- Sonarr/Radarr sync and batch upserts.lib/reencodarr/media/video_upsert.ex- guarded upsert logic, bitrate/VMAF handling.lib/reencodarr/media/video_state_machine.ex- valid state transitions.lib/reencodarr/ab_av1/output_parser.ex- sharedab-av1output parsing.lib/reencodarr/diagnostics.ex-bin/rpclive inspection surface..iex.exs- local console helpers.