SubtitleEdit/subtitleedit · error · InvalidOperationException
ffmpeg failed to extract chunk {i + 1}/{boundaries.Count} ({
Error message
ffmpeg failed to extract chunk {i + 1}/{boundaries.Count} ({boundary.StartSeconds:0.##}s → {boundary.EndSeconds:0.##}s) from {audioFileName} What it means
OpenAiSttChunker.ExtractChunkAsync returned false (ffmpeg exited non-zero), so the chunk WAV for the i-th boundary was not produced. The ViewModel surfaces it as InvalidOperationException naming the chunk index, the start/end seconds, and the source audio file.
Source
Thrown at src/ui/Features/Video/SpeechToText/SpeechToTextViewModel.cs:1601
var boundary = boundaries[i];
var chunkPath = Path.Combine(GetSttTempFolder(), $"se-stt-chunk-{Guid.NewGuid()}{extension}");
// Register before extraction so a throw mid-extract still drains
// the (possibly partial) file via the outer _filesToDelete sweep.
_filesToDelete.Add(chunkPath);
LogToConsole(
$"Chunk {i + 1}/{boundaries.Count}: " +
$"{TimeSpan.FromSeconds(boundary.StartSeconds):mm\\:ss} → {TimeSpan.FromSeconds(boundary.EndSeconds):mm\\:ss}");
try
{
var extractOk = await OpenAiSttChunker.ExtractChunkAsync(
ffmpegPath, audioFileName, chunkPath,
boundary.StartSeconds, boundary.DurationSeconds, cancellationToken);
if (!extractOk)
{
throw new InvalidOperationException(
$"ffmpeg failed to extract chunk {i + 1}/{boundaries.Count} " +
$"({boundary.StartSeconds:0.##}s → {boundary.EndSeconds:0.##}s) from {audioFileName}");
}
// Wrap the caller's segment progress so streaming segments coming
// from this chunk get offset back to absolute time before the UI
// sees them.
var offsetSeconds = boundary.StartSeconds;
var offsettingProgress = new Progress<OpenAiCompatibleSegment>(seg =>
{
segmentProgress.Report(new OpenAiCompatibleSegment
{
Id = seg.Id,
Start = seg.Start + offsetSeconds,
End = seg.End + offsetSeconds,
Text = seg.Text,
});
});View on GitHub (pinned to 17a9f07487)
Solutions
- Confirm ffmpegPath resolves to a working ffmpeg binary (run `ffmpeg -version`).
- Verify audioFileName exists and is decodable.
- Check boundary.StartSeconds/DurationSeconds produce a positive, in-range duration.
- Run the exact ffmpeg command ExtractChunkAsync builds, manually, to read the underlying stderr.
Example fix
// before: pass boundaries without sanity-checking
// after: skip degenerate boundaries before extracting
if (boundary.DurationSeconds <= 0 || boundary.EndSeconds > totalAudioSeconds)
{
LogToConsole($"Skipping degenerate chunk {i + 1}");
continue;
} Defensive patterns
Strategy: validation
Validate before calling
if (!File.Exists(ffmpegPath)) return Invalid("ffmpeg not found at " + ffmpegPath);
if (!File.Exists(audioFileName)) return Invalid("audio file missing");
if (boundary.DurationSeconds <= 0) return Invalid("zero-length chunk"); Try / catch
try { extractOk = await OpenAiSttChunker.ExtractChunkAsync(...); }
catch (InvalidOperationException ex) when (ex.Message.Contains("ffmpeg failed to extract chunk"))
{ /* log chunk index + boundary, continue or abort the run */ } Prevention
- Validate ffmpegPath at engine startup, not per chunk.
- Sanity-check boundary ranges against total audio duration before extracting.
- Run the exact ffmpeg command manually when extraction fails to read stderr.
When it happens
Trigger: ffmpegPath does not resolve to a working ffmpeg; audioFileName is missing/corrupt/undecodable; boundary.StartSeconds/EndSeconds are out of range or produce zero/negative DurationSeconds; output chunkPath is on a non-writable directory.
Common situations: ffmpeg not installed or moved after settings saved; truncated audio file; rounding errors producing 0-length chunks at the very start/end of short clips; permissions on the temp chunk folder.
Related errors
- Could not cut the audio window with ffmpeg.
- DashScope transcription timed out after {_settings.TimeoutSe
- DashScope upload-policy request failed ({(int)policyResponse
- DashScope upload-policy response could not be parsed. Respon
- DashScope OSS upload failed ({(int)uploadResponse.StatusCode
AI-assisted analysis of SubtitleEdit/subtitleedit@17a9f07487 (2026-08-13).
Data as JSON: /api/errors/236c2c12f6239ae7.
Report an issue: GitHub.