← Back to list

WebRTC: Images to video streaming in Golang

Encode RGBA/YUV images to VP8 buffer with WebRTC streaming

Andy · 2019-03-10 13:26 · 115 claps · 0.6 min read
#webrtc #yuv #vp8 #golang #streaming-video
Open on Medium ↗
Wiki topics: 🎬 · Film & Television

WebRTC: Images to video streaming in Golang

Encode RGBA/YUV images to VP8 buffer with WebRTC streaming

Github poi5305/go-yuv2webRTC

screenshot package

For capturing PC screen in RGBA format and convert it to YUV format

rgbaImage := screenshot.GetScreenshot(0, 0, screenWidth, screenHeight, resizeWidth, resizeHeight)
yuv := screenshot.RgbaToYuv(rgbaImg)

webrtc package

For creating p2p connection and streaming VP8 frame

webRTC := webrtc.NewWebRTC()
webRTC.ImageChannel <- yuv 
// convert yuv to vpx inner

vpx-encoder package

For compressing YUV format to VP8 frame format

encoder, err := vpxEncoder.NewVpxEncoder(width, height, 20, 1200, 5)
encoder.Input <- yuv
bs := <-encoder.Output
// bs(bytes)is in vp8 format
// In webRTC
vp8Track.Samples <- media.RTCSample{Data: bs, Samples: 1}

Example

go run main.go


메타데이터
post_id
e8e0ec09bfcc
slug
webrtc-images-to-video-streaming-in-golang-e8e0ec09bfcc
url
https://medium.com/@punpun/webrtc-images-to-video-streaming-in-golang-e8e0ec09bfcc
canonical_url
https://medium.com/@punpun/webrtc-images-to-video-streaming-in-golang-e8e0ec09bfcc
author_url
https://medium.com/@punpun
status
ok
fetched_at
2026-06-14 11:28:49