Vidio is a package providing simple Video I/O in Go using FFmpeg. It allows the user to manipulate videos frame by frame, access the webcam, and create videos.
Install with: go get github.com/AlexEidt/Vidio
Consider the example below, which loops through every frame an input video input.mp4
and writes them to a new video called output.mp4
. The audio from input.mp4
is also copied over. Note that this is just a simple example of copying a video, however other video processing could happen here as well.
video, err := vidio.NewVideo("input.mp4")
options := vidio.Options{
FPS: video.FPS(),
Bitrate: video.Bitrate(),
// If "input.mp4" does not have any audio, do not include the "Audio" field.
Audio: "input.mp4",
}
writer, err := vidio.NewVideoWriter(
"output.mp4",
video.Width(),
video.Height(),
&options
)
defer writer.Close()
for video.Read() {
writer.Write(video.FrameBuffer())
}
Project source: GitHub - AlexEidt/Vidio: FFmpeg wrapper providing simple, cross-platform Video I/O, GIF Creation, and Webcam Streaming in Go.