A Quick Post
So I’m working on a small project for fun, and I’m once again using PubNub to transfer data to end users. I wanted to stream a live video feed across all common browsers to include Safari for iOS devices. This means that I can’t use WebRTC, and to keep things simple then, I just wanted to stream JPEG frames at 15 frames per second.
It turned out that this program was so incredibly easy to write that I couldn’t resist just putting together a quick blog post.
Server Side Code
This assumes that you have some sort of JPEG generator in place. If you want to set up a test program, you can just write a quick script that opens a folder filled with jpegs and iterates over them continuously. Otherwise, this code is decoupled from reading from a camera or something (but you can also check out my other post on reading JPEG frames from SLRs here
Pretty simple, right? Keep in mind that the max packet size accepted by PubNub is 32 KB. In my case I generated JPEGs that are somewhat low quality and are about 200 by 300 pixels.
Client Side Code
If you just write your own jpeg generator function, this is absolutely all you need to set up a broadcasted video feed.