{"record":{"id":"c5d33161c60dc784","repo":"SubtitleEdit/subtitleedit","slug":"could-not-extract-the-current-frame-see-log-for","errorCode":null,"errorMessage":"Could not extract the current frame - see log for the ffmpeg command line.","messagePattern":"Could not extract the current frame - see log for the ffmpeg command line\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/ui/Features/Video/VideoOcr/VideoOcrViewModel.cs","lineNumber":557,"sourceCode":"        {\n            return;\n        }\n\n        ClampSelection();\n\n        _cancellationTokenSource = new CancellationTokenSource();\n        var cancellationToken = _cancellationTokenSource.Token;\n\n        IsRunning = true;\n        ProgressText = Se.Language.Video.VideoOcr.TestOcrRunning;\n\n        var frameFileName = Path.Combine(Path.GetTempPath(), \"se_video_ocr_test_\" + Guid.NewGuid() + \".jpg\");\n        try\n        {\n            await ExtractSingleFrame(frameFileName, PreviewPositionSeconds, cancellationToken);\n            if (!File.Exists(frameFileName) || new FileInfo(frameFileName).Length == 0)\n            {\n                throw new Exception(\"Could not extract the current frame - see log for the ffmpeg command line.\");\n            }\n\n            var group = new VideoOcrFrameGroup { RepresentativeFileName = frameFileName };\n            await OcrGroups(new List<VideoOcrFrameGroup> { group }, () => { }, _ => { }, cancellationToken);\n\n            ProgressText = string.IsNullOrWhiteSpace(group.Text)\n                ? Se.Language.Video.VideoOcr.TestOcrNoTextFound\n                : string.Format(Se.Language.Video.VideoOcr.TestOcrResultX, group.Text.ReplaceLineEndings(\" | \"));\n        }\n        catch (OperationCanceledException)\n        {\n            ProgressText = string.Empty;\n        }\n        catch (Exception exception)\n        {\n            Se.LogError(exception, \"Video OCR: test on current frame failed\");\n            ProgressText = string.Empty;\n","sourceCodeStart":539,"sourceCodeEnd":575,"githubUrl":"https://github.com/SubtitleEdit/subtitleedit/blob/17a9f0748781032255db3526b7215d2fb891e3af/src/ui/Features/Video/VideoOcr/VideoOcrViewModel.cs#L539-L575","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nawait ExtractSingleFrame(frameFileName, PreviewPositionSeconds, cancellationToken);\nif (!File.Exists(frameFileName) || new FileInfo(frameFileName).Length == 0)\n    throw new Exception(\"Could not extract the current frame - see log for the ffmpeg command line.\");\n\n// after - clamp inputs and surface ffmpeg's exit code in the message\nvar pos = Math.Clamp(PreviewPositionSeconds, 0, Math.Max(0, VideoDuration - 0.1));\nawait ExtractSingleFrame(frameFileName, pos, cancellationToken);\nif (!File.Exists(frameFileName) || new FileInfo(frameFileName).Length == 0)\n    throw new Exception($\"Could not extract the current frame (ffmpeg exit {_ffmpegExitCode}) - see log for the command line.\");","handlingStrategy":"validation","validationCode":"// Clamp selection inside the video and the seek position inside [0,duration).\nvar x = Math.Clamp(SelectionX, 0, Math.Max(0, VideoWidth - 1));\nvar y = Math.Clamp(SelectionY, 0, Math.Max(0, VideoHeight - 1));\nvar w = Math.Min(SelectionWidth, VideoWidth - x);\nvar h = Math.Min(SelectionHeight, VideoHeight - y);\nvar pos = Math.Clamp(PreviewPositionSeconds, 0, Math.Max(0, VideoDuration - 0.1));","typeGuard":null,"tryCatchPattern":"try { await ExtractSingleFrame(...); }\ncatch (OperationCanceledException) { ProgressText = string.Empty; }\ncatch (Exception ex)\n{\n    SeLogger.Error(ex, \"Video OCR: test on current frame failed\");\n    await MessageBox.Show(Window!, Se.Language.General.Error, ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Error);\n}","preventionTips":["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."],"tags":["ffmpeg","video-ocr","frame-extraction","ocr"],"backgroundTag":null,"analyzedSha":"17a9f0748781032255db3526b7215d2fb891e3af","analyzedAt":"2026-08-13T18:11:43.374Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}