Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for mjpg #31

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions examples/http_mjpeg_streamer/webcam.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (

const (
V4L2_PIX_FMT_PJPG = 0x47504A50
V4L2_PIX_FMT_MJPG = 0x47504a4d
V4L2_PIX_FMT_YUYV = 0x56595559
)

Expand All @@ -45,6 +46,7 @@ func (slice FrameSizes) Swap(i, j int) {

var supportedFormats = map[webcam.PixelFormat]bool{
V4L2_PIX_FMT_PJPG: true,
V4L2_PIX_FMT_MJPG: true,
V4L2_PIX_FMT_YUYV: true,
}

Expand Down Expand Up @@ -219,6 +221,9 @@ func encodeToImage(wc *webcam.Webcam, back chan struct{}, fi chan []byte, li cha

}
img = yuyv
case V4L2_PIX_FMT_MJPG:
mjpg, _, _ := image.Decode(bytes.NewReader(frame))
img = mjpg
default:
log.Fatal("invalid format ?")
}
Expand Down