Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nsmith5/mjpeg
Motion JPEG streaming library for Golang
https://github.com/nsmith5/mjpeg
golang mjpeg
Last synced: 2 days ago
JSON representation
Motion JPEG streaming library for Golang
- Host: GitHub
- URL: https://github.com/nsmith5/mjpeg
- Owner: nsmith5
- License: mit
- Created: 2020-05-13T00:09:32.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2020-09-13T18:18:43.000Z (about 4 years ago)
- Last Synced: 2024-10-31T04:34:51.505Z (14 days ago)
- Topics: golang, mjpeg
- Language: Go
- Homepage:
- Size: 10.7 KB
- Stars: 12
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Simple Motion JPEG Streaming
| Docs | Build |
|:-------|:------|
| [![GoDoc](https://godoc.org/github.com/nsmith5/mjpeg?status.svg)](https://godoc.org/github.com/nsmith5/mjpeg) | [![Build Status](https://cloud.drone.io/api/badges/nsmith5/mjpeg/status.svg)](https://cloud.drone.io/nsmith5/mjpeg) |Super simple mjpeg streaming in Go.
## Getting Started
Get to package with `go get github.com/nsmith5/mjpeg`. An MJPeg stream
can be built using any function that takes no arguments and returns an image.```go
package mainimport (
"log"
"net/http""github.com/nsmith5/mjpeg"
)func main() {
stream := mjpeg.Handler{
Next: func() (image.Image, error) {
img := image.NewGray(image.Rect(0, 0, 100, 100))
for i := 0; i < 100; i++ {
for j := 0; j < 100; j++ {
n := rand.Intn(256)
gray := color.Gray{uint8(n)}
img.SetGray(i, j, gray)
}
}
return img, nil
},
Options: &jpeg.Options{Quality: 80},
}mux := http.NewServeMux()
mux.Handle("/stream", stream)
log.Fatal(http.ListenAndServe(":8080", mux))
}
```