NickeManarin/ScreenToGif · error · Exception
Error while capturing frames with FFmpeg.
Error message
Error while capturing frames with FFmpeg.
What it means
Thrown by VideoSourceViewModel after an FFmpeg process exits with non-empty StandardError output. The method starts FFmpeg to extract frames from a video, awaits its exit, then checks if error text was written. If so, it throws with the FFmpeg command arguments and error output embedded in the exception's HelpLink.
Solutions
- Read the exception's HelpLink which contains the FFmpeg command and stderr output — this pinpoints the exact FFmpeg error.
- Verify the FFmpeg binary version supports the input codec (run 'ffmpeg -codecs').
- Check the input video file is not corrupted (play it in a media player).
- Ensure the output/temp directory has write permissions and sufficient disk space.
- Update FFmpeg to a recent build with all common codecs enabled.
Example fix
// before
if (!string.IsNullOrWhiteSpace(error))
throw new Exception("Error while capturing frames with FFmpeg.") { HelpLink = $"Command:\n\r{info.Arguments}\n\rResult:\n\r{error}" };
// after: include error directly in message for easier debugging, check exit code
if (_process.ExitCode != 0 || !string.IsNullOrWhiteSpace(error))
throw new Exception($"Error while capturing frames with FFmpeg (exit {_process.ExitCode}): {error}")
{ HelpLink = $"Command:\n\r{info.Arguments}" }; Defensive patterns
Strategy: try-catch
Validate before calling
// Validate input file before starting FFmpeg
if (!File.Exists(inputPath))
throw new FileNotFoundException("Input video not found", inputPath);
var info = new FileInfo(inputPath);
if (info.Length == 0)
throw new InvalidDataException("Input video file is empty.");
if (!File.Exists(ffmpegPath))
throw new FileNotFoundException("FFmpeg binary not found", ffmpegPath); Try / catch
// The existing catch block at line 770 already handles this: // it logs, sets IsImporting=false, and shows a user error dialog. // Ensure e.HelpLink (containing FFmpeg stderr) is shown to the user.
Prevention
- Validate the input video file exists and is non-empty before launching FFmpeg.
- Verify the FFmpeg binary path and version before use.
- Check that the output/temp directory has write permission and free disk space.
- Parse FFmpeg's exit code separately from stderr — exit code 0 with stderr output is normal for FFmpeg.
When it happens
Trigger: FFmpeg process runs (info.Arguments) and exits, but writes error messages to stderr. Common FFmpeg errors: unsupported codec, corrupt input file, invalid arguments, missing encoder, permission denied on output path, or the input video file is unreadable.
Common situations: User selects a video with a codec FFmpeg doesn't support (rare but possible with custom builds). FFmpeg binary is not found or is an older version lacking the needed decoder. Output folder is read-only. Input video file is corrupted or truncated. FFmpeg arguments (e.g., filter, fps) are misconfigured.
Related errors
- Can't get language codes. Path to language codes is null
- Error while encoding the
- FFmpeg not present.
- output
AI-assisted analysis of NickeManarin/ScreenToGif@a4d0a67c21 (2026-08-13).
Data as JSON: /api/errors/e2a69bab63a3a497.
Report an issue: GitHub.
Appendix: source
Thrown at ScreenToGif.ViewModel/VideoSourceViewModel.cs:768
if (Math.Abs(current - FrameCount) < double.Epsilon)
GetFiles(folder);
}
};
_process.StartInfo = info;
_process.Start();
_process.BeginOutputReadLine();
_process.BeginErrorReadLine();
await _process.WaitForExitAsync();
if (_process == null)
return;
var error = await _process?.StandardError?.ReadToEndAsync();
if (!string.IsNullOrWhiteSpace(error))
throw new Exception("Error while capturing frames with FFmpeg.") { HelpLink = $"Command:\n\r{info.Arguments}\n\rResult:\n\r{error}" };
}
catch (Exception e)
{
LogWriter.Log(e, "Error importing frames with FFmpeg");
IsImporting = false;
Dispatcher.CurrentDispatcher.Invoke(() => ShowErrorRequested?.Invoke(this, LocalizationHelper.Get("S.ImportVideo.Error") + Environment.NewLine + e.Message + Environment.NewLine + e.HelpLink));
}
}
private void ImportAndSeek()
{
if (_cancelled)
return;
lock (_lock)
{View on GitHub (pinned to a4d0a67c21)