MathewSachin/Captura · error · Exception
Cannot connect Video pipe to FFmpeg
Error message
Cannot connect Video pipe to FFmpeg
What it means
Thrown by FFmpegWriter.WriteFrame (src/Captura.FFmpeg/Video/FFmpegVideoWriter.cs:216) when _ffmpegIn.WaitForConnection(5000) returns false on the first frame. FFmpeg must open the `captura-<guid>` video pipe within 5s; if it never does, the timeout fires. This is the first interaction with ffmpeg after StartFFmpeg, so a failure here usually means ffmpeg failed to start or rejected its arguments.
Source
Thrown at src/Captura.FFmpeg/Video/FFmpegVideoWriter.cs:216
Task _lastFrameTask;
/// <summary>
/// Writes an Image frame.
/// </summary>
public void WriteFrame(IBitmapFrame Frame)
{
if (_ffmpegProcess.HasExited)
{
Frame.Dispose();
throw new FFmpegException(_ffmpegProcess.ExitCode);
}
if (_firstFrame)
{
if (!_ffmpegIn.WaitForConnection(5000))
{
throw new Exception("Cannot connect Video pipe to FFmpeg");
}
_firstFrame = false;
}
if (_lastFrameTask == null)
{
_lastFrameTask = Task.CompletedTask;
}
if (!(Frame is RepeatFrame))
{
using (Frame)
{
if (Frame.Unwrap() is INV12Frame nv12Frame)
{
nv12Frame.CopyNV12To(_videoBuffer);
}View on GitHub (pinned to 3fdf41529b)
Solutions
- Check _ffmpegProcess.HasExited right after StartFFmpeg in the constructor; if dead, read the log immediately.
- Confirm FFmpegExePath resolves to a real executable (not the fallback bare name).
- Log argsBuilder.GetArgs() and reproduce the command manually.
- Raise the 5000 ms connect timeout on slow machines.
Example fix
// before
if (!_ffmpegIn.WaitForConnection(5000))
throw new Exception("Cannot connect Video pipe to FFmpeg");
// after
if (!_ffmpegIn.WaitForConnection(5000))
throw new Exception(_ffmpegProcess.HasExited
? $"FFmpeg exited (code {_ffmpegProcess.ExitCode}) before opening the video pipe; args: {args}"
: "Video pipe connect timed out after 5s"); Defensive patterns
Strategy: validation
Validate before calling
// right after StartFFmpeg in the ctor, fail fast with the real reason
_ffmpegProcess = FFmpegService.StartFFmpeg(argsBuilder.GetArgs(), Args.FileName, out _);
if (_ffmpegProcess.HasExited) // ffmpeg rejected args and died immediately
throw new FFmpegException(_ffmpegProcess.ExitCode); Try / catch
try { /* first WriteFrame */ }
catch (Exception e) when (e.Message.Contains("Video pipe")) { var reason = _ffmpegProcess.HasExited ? $"exit {_ffmpegProcess.ExitCode}" : "timeout"; /* report reason */ } Prevention
- Check _ffmpegProcess.HasExited immediately after StartFFmpeg.
- Confirm FFmpegExePath resolves to a real file, not the bare fallback name.
- Log argsBuilder.GetArgs() so a failed connect can be reproduced manually.
When it happens
Trigger: The first WriteFrame call when ffmpeg did not connect to the video named pipe within 5000 ms. Typically ffmpeg exited immediately after start (bad args, missing binary resolution via FFmpegExePath) or is still alive but stalled.
Common situations: FFmpegExePath resolved to a bare `ffmpeg.exe` name that isn't on PATH; the rawvideo/nv12 args are malformed; ffmpeg process started but the named-pipe path format is wrong for this OS; system too loaded to start ffmpeg in 5s.
Related errors
- Cannot connect Audio pipe to FFmpeg
- FFmpeg could not be found. Please download using the in-buil
- An Error Occurred with FFmpeg, Exit Code: {ExitCode}.\nSee F
- FFmpeg could not be found. Please download using the in-buil
- An Error Occurred with FFmpeg, Exit Code: {ExitCode}.\nSee F
AI-assisted analysis of MathewSachin/Captura@3fdf41529b (2026-08-13).
Data as JSON: /api/errors/5c06f26444e9e730.
Report an issue: GitHub.