

This will combine the video with all other streams in the given file (Audio, Subtitle, Data, and Attachments Streams) and will cut all streams to be the same length. Instead of having to process the video and store in a file and then combine with the original audio later, the user can simply pass in the original file path via the Options.StreamFile parameter. The Options.StreamFile parameter is intended for users who wish to process a video stream and keep the audio (or other streams). StreamFile string // File path for extra stream data. Quality float64 // If bitrate not given, use quality instead. Macro int // Macroblock size for determining how to resize frames for codecs.įPS float64 // Frames per second for output video. 1=no loop, 0=infinite loop, >0=number of loops.ĭelay int // Delay for final frame of GIFs in centiseconds. vidio.NewVideoWriter(filename string, width, height int, options *vidio.Options) (*vidio.VideoWriter, error) This contains all the desired properties of the new video you want to create.

The only required parameters are the output file name, the width and height of the frames being written, and an Options struct. The VideoWriter is used to write frames to a video file.

vidio.NewCamera(stream int) (*vidio.Camera, error) On most machines the webcam device has index 0. The Camera can read from any cameras on the device running Vidio. If not all frames are read, call video.Close() to close the video. If all frames have been read, video will be closed automatically. Vidio.NewVideoStreams(filename string) (*vidio.Video, error) vidio.NewVideo(filename string) (*vidio.Video, error) Note that the A (alpha) component will always be 255. The code below shows an example of sequentially reading the frames of the given video.Ĭalling the Read() function will fill in the Video struct framebuffer with the next frame data as 8-bit RGBA data, stored in a flattened byte array in row-major order where each pixel is represented by four consecutive bytes representing the R, G, B and A components of that pixel. The Video struct stores data about a video file you give it. This library relies on FFmpeg, and FFProbe which must be downloaded before usage and added to the system path.Īll frames are encoded and decoded in 8-bit RGBA format.įor Audio I/O using FFmpeg, see the aio project.

NewVideoWriter(filename, width, height, options)Ī simple Video I/O library written in Go.
