Discover Packages
github.com/garymcbay/mjpeg
package
module
Version:
v0.0.0-...-531a153
Opens a new window with list of versions in this module.
Published: Mar 10, 2021
License: MIT
Opens a new window with license information.
Imports: 6
Opens a new window with list of imports.
Imported by: ? modules, 0 packages
The first number is the count of modules that contain a package that imports this one.
The module count is a better indicator of popularity than the package count.
A module with 100 importing packages is counted only once instead of 100 times,
reflecting the fact that the choice to use the package was likely made only once,
not 100 times.
A '?' means that the value hasn't been computed yet.
Opens a new window with list of known importers.
README
README
¶
Forked from HybridGroup
Changes
Adds support for streaming an MJPEG http response to Echo web server.
Added new func StreamToEcho.
StreamToEcho implements echo.Context to set header to image/jpeg content-type.
Writes mjpeg buffer to an Echo-type response and streams to http.
How to use
Initialise standard Echo server as per .
Define a Echo HTTP GET route.
Pass new StreamToEcho func as the handler.
Code Example
package main
import (
"github.com/GaryMcBay/mjpeg"
"github.com/labstack/echo"
)
func main() {
e := echo.New()
stream := mjpeg.NewStream()
e.GET("/capture", stream.StreamToEcho)
// Pass your jpegBuffer frames using stream.UpdateJPEG(<your-buffer>)
// Start server
e.Logger.Fatal(e.Start(":8080"))
}
Expand ▾
Collapse ▴
Documentation
¶
Package mjpeg implements a simple MJPEG streamer.
Stream objects implement the http.Handler interface, allowing to use them with the net/http package like so:
stream = mjpeg.NewStream()
http.Handle("/camera", stream)
Then push new JPEG frames to the connected clients using stream.UpdateJPEG().
Stream represents a single video feed.
NewStream initializes and returns a new Stream.
ServeHTTP responds to HTTP requests with the MJPEG stream, implementing the http.Handler interface.
StreamToEcho implements Echo headers to respond to Echo HTTP requests with an MJPEG stream.
UpdateJPEG pushes a new JPEG frame onto the clients.
Source Files
¶
Click to show internal directories.
Click to hide internal directories.