SubtitleEdit/subtitleedit · error · Exception
Could not extract the current frame - see log for the ffmpeg
Error message
Could not extract the current frame - see log for the ffmpeg command line.
What it means
Thrown in VideoOcrViewModel.TestOcrOnCurrentFrame after ExtractSingleFrame runs ffmpeg to produce one JPEG: the frame file either does not exist or is zero-length, meaning ffmpeg failed to capture the cropped frame at PreviewPositionSeconds. The exception is caught locally (OperationCanceledException is handled separately) and surfaced to the user via MessageBox after Se.LogError. The real diagnostic is the ffmpeg command line written to the tools log.
Source
Thrown at src/ui/Features/Video/VideoOcr/VideoOcrViewModel.cs:557
{
return;
}
ClampSelection();
_cancellationTokenSource = new CancellationTokenSource();
var cancellationToken = _cancellationTokenSource.Token;
IsRunning = true;
ProgressText = Se.Language.Video.VideoOcr.TestOcrRunning;
var frameFileName = Path.Combine(Path.GetTempPath(), "se_video_ocr_test_" + Guid.NewGuid() + ".jpg");
try
{
await ExtractSingleFrame(frameFileName, PreviewPositionSeconds, cancellationToken);
if (!File.Exists(frameFileName) || new FileInfo(frameFileName).Length == 0)
{
throw new Exception("Could not extract the current frame - see log for the ffmpeg command line.");
}
var group = new VideoOcrFrameGroup { RepresentativeFileName = frameFileName };
await OcrGroups(new List<VideoOcrFrameGroup> { group }, () => { }, _ => { }, cancellationToken);
ProgressText = string.IsNullOrWhiteSpace(group.Text)
? Se.Language.Video.VideoOcr.TestOcrNoTextFound
: string.Format(Se.Language.Video.VideoOcr.TestOcrResultX, group.Text.ReplaceLineEndings(" | "));
}
catch (OperationCanceledException)
{
ProgressText = string.Empty;
}
catch (Exception exception)
{
Se.LogError(exception, "Video OCR: test on current frame failed");
ProgressText = string.Empty;
View on GitHub (pinned to 17a9f07487)
Solutions
- Open the tools log and copy the exact 'Video OCR: extracting test frame - ffmpeg ...' line, run it manually to see ffmpeg's stderr.
- Verify the selection rectangle is fully inside the video (SelectionX+Width <= VideoWidth, SelectionY+Height <= VideoHeight) and PreviewPositionSeconds is within [0, duration).
- Confirm ffmpeg is present and runnable (SE's bundled ffmpeg) and the temp folder (%TEMP%) is writable.
- If the source is corrupt, re-encode/remux it (ffprobe first) before OCR.
Example fix
// before
await ExtractSingleFrame(frameFileName, PreviewPositionSeconds, cancellationToken);
if (!File.Exists(frameFileName) || new FileInfo(frameFileName).Length == 0)
throw new Exception("Could not extract the current frame - see log for the ffmpeg command line.");
// after - clamp inputs and surface ffmpeg's exit code in the message
var pos = Math.Clamp(PreviewPositionSeconds, 0, Math.Max(0, VideoDuration - 0.1));
await ExtractSingleFrame(frameFileName, pos, cancellationToken);
if (!File.Exists(frameFileName) || new FileInfo(frameFileName).Length == 0)
throw new Exception($"Could not extract the current frame (ffmpeg exit {_ffmpegExitCode}) - see log for the command line."); Defensive patterns
Strategy: validation
Validate before calling
// Clamp selection inside the video and the seek position inside [0,duration). var x = Math.Clamp(SelectionX, 0, Math.Max(0, VideoWidth - 1)); var y = Math.Clamp(SelectionY, 0, Math.Max(0, VideoHeight - 1)); var w = Math.Min(SelectionWidth, VideoWidth - x); var h = Math.Min(SelectionHeight, VideoHeight - y); var pos = Math.Clamp(PreviewPositionSeconds, 0, Math.Max(0, VideoDuration - 0.1));
Try / catch
try { await ExtractSingleFrame(...); }
catch (OperationCanceledException) { ProgressText = string.Empty; }
catch (Exception ex)
{
SeLogger.Error(ex, "Video OCR: test on current frame failed");
await MessageBox.Show(Window!, Se.Language.General.Error, ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Error);
} Prevention
- Inspect the ffmpeg command in the tools log whenever this fires.
- Keep the selection rectangle fully inside the video bounds.
- Confirm ffmpeg is installed and the temp folder is writable before testing.
When it happens
Trigger: ffmpeg exited non-zero or produced no output: invalid seek position (PreviewPositionSeconds beyond EOF or negative), a crop filter region outside the video bounds (SelectionX/Y/Width/Height invalid), unsupported/corrupt video codec, ffmpeg binary missing, or the temp folder not writable.
Common situations: User drew an OCR selection box partly outside the video; preview position is at the very end of a trimmed file; ffmpeg not installed/on PATH; corrupt source video; permissions on the temp path.
Related errors
- No frames were extracted from the video - see log for the ff
- Paddle OCR failed: {paddleOcr.Error}
- {Se.Language.Ocr.CrispEmbedNotDownloaded}
- {engine.Error}
- {error}
AI-assisted analysis of SubtitleEdit/subtitleedit@17a9f07487 (2026-08-13).
Data as JSON: /api/errors/c5d33161c60dc784.
Report an issue: GitHub.