# README
ffmpego
ffmpego is a Go wrapper around the ffmpeg
command for reading and writing videos. It can be used to programmatically manipulate media with a simple, friendly interface.
Usage
Writing a video
To encode a video, create a VideoWriter
and write image.Image
s to it. Here's the simplest possible example of encoding a video:
fps := 24.0
width := 50
height := 50
vw, _ := ffmpego.NewVideoWriter("output.mp4", width, height, fps)
for i := 0; i < 24; i++ {
// Create your image.
frame := image.NewGray(image.Rect(0, 0, width, height))
vw.WriteFrame(frame)
}
vw.Close()
Reading a video
Decoding a video is similarly straightforward. Simply create a VideoReader
and read image.Image
s from it:
vr, _ := NewVideoReader("input.mp4")
for {
frame, err := vr.ReadFrame()
if err == io.EOF {
break
}
// Do something with `frame` here...
}
vr.Close()
Installation
This project depends on the ffmpeg
command. If you have ffmpeg
installed, ffmpego should already work out of the box.
If you do not already have ffmpeg, you can typically install it using your OS's package manager.
Ubuntu:
$ apt install ffmpeg
macOS:
$ brew install ffmpeg
# Packages
No description provided by the author
# Functions
CreateChildStream creates a ChildStream suitable for use on the current operating system.
GetAudioInfo gets information about a audio file.
GetVideoInfo gets information about a video file.
No description provided by the author
NewAudioReaderResampled creates an AudioReader that automatically changes the input frequency.
NewAudioWriter creates a AudioWriter which is encoding mono-channel audio to the given file.
NewChildPipeStream creates a ChildPipeStream.
NewChildSocketStream creates a ChildSocketStream.
No description provided by the author
NewVideoReaderResampled creates a VideoReader that automatically changes the input frame rate.
NewVideoWriter creates a VideoWriter which is encoding to the given file.
NewVideoWriterWithAudio creates a VideoWriter which copies audio from an existing video or audio file.
# Structs
AudioInfo stores information about an audio file.
A AudioReader decodes an audio file using ffmpeg.
An AudioWriter encodes an audio file using ffmpeg.
A ChildPipeStream uses a pipe to communicate with subprocesses.
A ChildSocketStream uses a TCP socket to communicate with subprocesses.
VideoInfo is information about an encoded video.
A VideoReader decodes a video file using ffmpeg.
A VideoWriter encodes a video file using ffmpeg.
# Interfaces
A ChildStream is a connection to an ffmpeg process.