Class FfmpegVideoWriter
An IVideoWriter that pipes raw frames to an ffmpeg process and writes an H.264 mp4, as moviepy
does for Gymnasium: libx264 at the medium preset, yuv420p when both sides are even.
public sealed class FfmpegVideoWriter : IVideoWriter
- Inheritance
-
FfmpegVideoWriter
- Implements
- Inherited Members
- Extension Methods
Remarks
ffmpeg must be installed; it is looked up on PATH unless Executable names it. Each
video starts one process and waits for it; the frames stream through its standard input, so memory stays at one
frame. The bytes differ from moviepy's (another encoder build and options), which DR-25 accepts: parity is on
frames.
Properties
Codec
The video codec (-vcodec), libx264 as moviepy's default.
public string Codec { get; init; }
Property Value
Executable
The ffmpeg executable: a path, or a name looked up on PATH.
public string Executable { get; init; }
Property Value
Extension
.mp4.
public string Extension { get; }
Property Value
Preset
The encoder preset (-preset), medium as moviepy's default.
public string Preset { get; init; }
Property Value
Methods
Write(string, IReadOnlyList<NDArray>, double)
Encodes the frames into {path}.mp4, replacing an existing file.
public void Write(string path, IReadOnlyList<NDArray> frames, double fps)
Parameters
pathstringThe video's path without extension.
framesIReadOnlyList<NDArray>The frames, all of one shape; they stay the caller's.
fpsdoubleThe frame rate.
Exceptions
- ArgumentNullException
Thrown when
pathorframesis null.- ArgumentException
Thrown for no frames, frames of different shapes, or a frame that is not an image.
- DependencyNotInstalled
Thrown when
ffmpegcannot be started.- Error
Thrown when
ffmpegfails, with its error output.