SubtitleEdit/subtitleedit · error · InvalidOperationException
Failed to initialize mpv: {_mpvContext.GetErrorString(err)}
Error message
Failed to initialize mpv: {_mpvContext.GetErrorString(err)} What it means
LibMpvDynamicPlayer.Initialize() returned a negative mpv error code; GetErrorString maps it to a human-readable string. This means the libmpv shared library could not be brought up — missing dependency, ABI mismatch, or init failure inside mpv itself. Thrown inside PlayAudio under _playLock after a fresh LibMpvDynamicPlayer is created each call.
Source
Thrown at src/ui/Features/Video/TextToSpeech/ActorVoices/ActorVoiceMappingViewModel.cs:418
{
row.IsPlaying = false;
generatingAudioVm.Close();
}
}
private async Task PlayAudio(string fileName)
{
lock (_playLock)
{
_mpvContext?.Stop();
_mpvContext?.Dispose();
_mpvContext = new LibMpvDynamicPlayer();
_mpvContext.LoadLib();
var err = _mpvContext.Initialize();
if (err < 0)
{
throw new InvalidOperationException($"Failed to initialize mpv: {_mpvContext.GetErrorString(err)}");
}
}
await _mpvContext.LoadAudio(fileName);
}
[RelayCommand]
private void ApplyDefaultToAll()
{
if (_fallbackEngine == null)
{
return;
}
foreach (var row in Rows)
{
if (row.SelectedEngine == _fallbackEngine)
{View on GitHub (pinned to 17a9f07487)
Solutions
- Re-ship/restore the libmpv binary in the application directory.
- Match libmpv architecture to the process bitness (x64 process needs x64 libmpv).
- Read _mpvContext.GetErrorString(err) in the message for the specific mpv error code.
- Reinstall the VC++ runtime and exclude the app folder from AV.
Example fix
// before: assume init always works
var err = _mpvContext.Initialize();
// after: keep the error string in the surface message (already done) and
// guard LoadLib separately
if (!_mpvContext.LoadLib())
throw new InvalidOperationException("libmpv not found next to the executable"); Defensive patterns
Strategy: try-catch
Validate before calling
if (!_mpvContext.LoadLib()) return Invalid("libmpv not found next to the executable"); Try / catch
try { await PlayAudio(fileName); }
catch (InvalidOperationException ex) when (ex.Message.Contains("Failed to initialize mpv"))
{ /* surface GetErrorString; offer to re-install libmpv */ } Prevention
- Ship the matching-architecture libmpv with the app.
- Call LoadLib() and check its bool before Initialize().
- Log GetErrorString(err) so the mpv error code is never lost.
When it happens
Trigger: LoadLib() succeeded but Initialize() < 0: libmpv dll/so missing from the app directory; wrong architecture (x86 vs x64) vs the process; corrupt libmpv; required codec/sentenceit libs absent; AV/sandbox blocking the dll.
Common situations: App moved without its libmpv binary; user replaced libmpv with an incompatible version; fresh machine missing VC++ runtime; antivirus quarantined the dll.
Related errors
- Voice is not a AllTalkVoice
- Voice is not an AzureVoice
- Voice is not a ChatterboxVoice
- Chatterbox TTS hit a CrispASR runtime bug during synthesis (
- Chatterbox TTS request failed — the crispasr server crashed
AI-assisted analysis of SubtitleEdit/subtitleedit@17a9f07487 (2026-08-13).
Data as JSON: /api/errors/8e8d39ee45fb0f17.
Report an issue: GitHub.