Skip to content

Bug: Saved encoder is ignored on startup — resets to H.264 NVENC (v1.2.2, Windows, NVIDIA) #45

@CKades

Description

@CKades

Summary
When I select H.265 (HEVC) in the Encoder dropdown and close the app, the choice is written to settings.json. On the next launch, the UI reverts to H.264 NVENC (NVIDIA) instead of honoring the saved setting.

Version

  • Anime4K-GUI v1.2.2
  • OS: Windows 10/11 x64
  • GPU: NVIDIA (NVENC available)
  • CPU: 24 threads (from settings)
  • FFmpeg: bundled

Steps to Reproduce

  1. Launch Anime4K-GUI.exe.
  2. In Encoder, choose H.265 (e.g., H.265 NVENC (NVIDIA)).
  3. Close the app.
  4. Open %USERPROFILE%\Downloads\Anime4K-GUI\settings.json and note the encoder value is saved:

{"use_saved_position":true,"position_x":164,"position_y":187,"resolution":7,"shaders":1,"encoder":3,"crf":18,"cq":12,"output_format":2,"cpu_threads":24,"debug_mode":false,"version":"1.2.2"}

(On my system encoder: 3 corresponds to H.265 NVENC.)

  1. Relaunch the app.

Expected

  • Encoder dropdown shows H.265 (the previously selected value).
  • The app uses the saved encoder for subsequent runs.

Actual

  • Encoder dropdown resets to H.264 NVENC (NVIDIA).
  • Saved value in settings.json is effectively ignored at startup.

Notes / Observations

  • Behavior is 100% reproducible.
  • Toggling Debug mode doesn’t change behavior

Likely Root Cause
Two things are probably happening at startup during encoder discovery:

  1. The app overwrites the loaded settings.encoder with the first available non-CPU encoder it finds (on NVIDIA, that’s H.264 NVENC).
  2. The encoder choice is persisted as an index into a dynamically built list, not a stable identifier. If the discovery code reorders encoders or reassigns index 0..N, a previously valid index can point at a different codec on next launch.

Suggested Fixes (any of these would solve it)

- Respect saved value if valid

After discovery, if settings.encoder is in range of availableEncoders, don’t change it. Only fall back when the saved index is out of bounds.

// Pseudocode
if savedIdx < 0 || savedIdx >= len(availableEncoders) {
// fallback: pick first non-CPU
for i, enc := range availableEncoders {
if enc.Vendor != "cpu" { savedIdx = i; break }
}
}
settings.Encoder = int32(savedIdx)

- Persist a stable key, not an index

Store something like "hevc_nvenc", "libx265", "h264_nvenc", "libaom-av1" in settings.json. At startup, map the key to the discovered encoder list; if not found, gracefully fall back and update the file.

// Example future format:
{"encoder_key":"hevc_nvenc", ...}

  • One-time migration

If you switch to keys, add a small migration step: when encoder_key is missing but encoder (index) exists, translate the old index once and write the new key.

  • UI affordance

Optional: a checkbox like “Prefer hardware encoder on startup” that, if enabled, allows the current “pick first non-CPU” behavior to override the saved value. Default off.

Workaround

  • Manually reselect H.265 each launch.

Impact

  • Users who prefer H.265 (NVENC or CPU) have to reconfigure on every run; easy to miss and leads to larger files and longer processing times than intended.

Acceptance Criteria

  • After selecting H.265 and closing the app, the next launch shows H.265 selected and uses it without any user action, as long as a compatible encoder is available.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions