Add example to README, copy buffer in Write

This commit is contained in:
Alex Eidt 2022-10-01 11:35:47 -07:00
parent f1c7d31a29
commit 68fe8618c6
2 changed files with 20 additions and 17 deletions

View file

@ -167,6 +167,23 @@ for i := 1; i <= 10; i++ {
}
```
Write all frames of `video.mp4` as `jpg` images.
```go
video, _ := vidio.NewVideo("video.mp4")
img := image.NewRGBA(image.Rect(0, 0, video.Width(), video.Height()))
video.SetFrameBuffer(img.Pix)
frame := 0
for video.Read() {
f, _ := os.Create(fmt.Sprintf("%d.jpg", frame))
jpeg.Encode(f, img, nil)
f.Close()
frame++
}
```
# Acknowledgements
* Special thanks to [Zulko](http://zulko.github.io/) and his [blog post](http://zulko.github.io/blog/2013/09/27/read-and-write-video-frames-in-python-using-ffmpeg/) about using FFmpeg to process video.