Class PngVideoWriter
The default IVideoWriter: each video a folder of PNG frames (000000.png, 000001.png,
...) and an fps.txt holding its frame rate. Needs no external program; ffmpeg -framerate {fps} -i
%06d.png out.mp4 turns a folder into a video.
public sealed class PngVideoWriter : IVideoWriter
- Inheritance
-
PngVideoWriter
- Implements
- Inherited Members
- Extension Methods
Remarks
A folder per video keeps Gymnasium's count of videos (len(os.listdir(video_folder))) and names. Writing
over an existing video first deletes the frames it wrote there (files named like its frames), so a shorter video
leaves none of a longer one's behind; other files in the folder are left alone. Frames of another dtype than uint8
are cast to uint8 first, as moviepy does.
Properties
Extension
The empty string: a video is a folder.
public string Extension { get; }
Property Value
Methods
Write(string, IReadOnlyList<NDArray>, double)
Writes the frames as {path}/000000.png, ... and the frame rate as {path}/fps.txt.
public void Write(string path, IReadOnlyList<NDArray> frames, double fps)
Parameters
pathstringThe video's folder, created if needed.
framesIReadOnlyList<NDArray>The frames; they stay the caller's.
fpsdoubleThe frame rate, written to
fps.txt.
Exceptions
- ArgumentNullException
Thrown when
pathorframesis null.- ArgumentException
Thrown for no frames, or a frame that is not an image of 2 or 3 dimensions.
- IOException
Thrown when a file cannot be written.