-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b0e8dad
commit f6add5f
Showing
1 changed file
with
59 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,63 @@ | ||
# ffmpego | ||
|
||
**ffmpego** is a Go wrapper around the `ffmpeg` command for reading and writing videos. It can be used to programmatically manipulate media in a simple way. | ||
**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: | ||
|
||
```go | ||
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: | ||
|
||
```go | ||
vr, _ := NewVideoReader("input.mp4") | ||
|
||
for { | ||
frame, err := reader.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 | ||
``` | ||
|