Skip to content

Video Encoding VP8, H264

giongto35 edited this page Aug 31, 2019 · 1 revision

Introduction

Video compression is an important part of WebRTC to ensure the smallest possible packets for smooth streaming.

VP8 Codec

VP8 is an open and free video compression format owned by Google. As in my understanding, VP8 will periodically pick some keyframe and construct new frames based on the difference. VP8 Reference Because Vp8 is owned by Google, it's not so popular and WebRTC just recently supported VP8 on some new browsers. The GoLang resource for VP8 Encoding is also very limited.

H264 Codec

H264 Codec is one of the most commonly used codec for the video encoding according to Wiki. H264 is going to be introduced to CloudRetro because it has more resource and library thanks to its popularity.

Video Compression in CloudRetro

Because Web browser already supports VP8 and H264 format for video stream. There is no decoding required on Frontend side. However, on the Backend side, after we fetch an image frame from the emulator, we need to encode it to video stream following some codec format. After we encode

Video encoding implementation

StartVideo func in media.go spawns a goroutine listen to image stream. Each image frame will be sent to encoding pipeline (encoder.Input) and then received the encoded image from (encoder.Output). This encoded image is then send to WebRTC Image channel to be sent to stream later.