Table of Contents

Class VideoFrameReader

Namespace
SharpConsoleUI.Video
Assembly
SharpConsoleUI.dll

Reads video frames as raw RGB24 byte arrays by piping from an FFmpeg subprocess. Each frame is width * height * 3 bytes (R, G, B per pixel, row-major).

public sealed class VideoFrameReader : IDisposable
Inheritance
VideoFrameReader
Implements
Inherited Members
Extension Methods

Properties

DurationSeconds

Video duration in seconds, or 0 if unknown.

public double DurationSeconds { get; }

Property Value

double

Fps

Video frame rate.

public double Fps { get; }

Property Value

double

FrameSize

Bytes per frame (Width * Height * 3).

public int FrameSize { get; }

Property Value

int

Height

Video height in pixels.

public int Height { get; }

Property Value

int

Width

Video width in pixels.

public int Width { get; }

Property Value

int

Methods

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

IsFfmpegAvailable()

Checks if the FFmpeg executable is available on the system PATH.

public static bool IsFfmpegAvailable()

Returns

bool

Open(string, int, int, double)

Opens a video source and starts the FFmpeg decode process. Accepts any source FFmpeg understands: local file paths, HTTP/HTTPS URLs, RTSP streams, HLS playlists (m3u8), RTMP, FTP, or any other FFmpeg-supported protocol. Probes metadata first, then launches the raw frame pipe.

public static VideoFrameReader Open(string source, int targetWidth, int targetHeight, double startTime = 0)

Parameters

source string

File path or URL. Anything FFmpeg's -i accepts.

targetWidth int

Target output width in pixels. FFmpeg scales to this.

targetHeight int

Target output height in pixels. FFmpeg scales to this.

startTime double

Optional start time in seconds for seeking. Ignored for live streams.

Returns

VideoFrameReader

A VideoFrameReader ready to read frames.

Exceptions

InvalidOperationException

If FFmpeg is not found or fails to start.

ReadFrame(byte[])

Reads the next frame into the provided buffer.

public bool ReadFrame(byte[] buffer)

Parameters

buffer byte[]

Must be at least FrameSize bytes.

Returns

bool

True if a full frame was read; false if end-of-stream.

ReadFrameAsync(byte[], CancellationToken)

Reads the next frame into the provided buffer asynchronously.

public Task<bool> ReadFrameAsync(byte[] buffer, CancellationToken ct = default)

Parameters

buffer byte[]

Must be at least FrameSize bytes.

ct CancellationToken

Cancellation token.

Returns

Task<bool>

True if a full frame was read; false if end-of-stream.