Let me explain my problem: I have 2 webcams looking out over the beach but my internet connection is very slow. So i'm looking for a way to buffer the videofeed to a server and then let my clients connect to that server instead of directly to the webcams.
Here's something I saw at github might answer your question.
This example demonstrate how to encode set of buffered images obtained from Webcam instance, transcode into h.264 stream and send to remote peer where it is decoded and rendered in panel.
Example provided by hepin1989. Thank you! This is wonderful piece of the good code :)
How To Use
- Run StreamServer - this will open the webcam device and start listening for incoming streaming requests.
- Run StreamClient - this will connect to the StreamServer and start displaying image from the remote camera. The server / client address is localhost by default to run client and server on the same machine, but if you want to stream over the network, you need to change it to reflect your real IP address (server must bind to eth0 instead of lo interface to be visible from the NAT).
- The code supports sunny-day scenario only, just to demonstrate the idea, so there are is no complex error checking statements and the code may behave in unexpected manner when launched in real network.
- It uses Xuggler which seems to be discontinued.
- Remember, this example is to present an idea, so if you need enhancement or bug fix, please implement it and send pull request to share it with community. Be creative :)
- To perform streaming over the network you need to change address in server from localhost to your real IP address (e.g. such as 192.168.1.10 or 0.0.0.0 in general). I'm not sure how it works with the IPv6 support - feel free to test it.
Livestream does this. It's built in, in terms of functionality of a drift buffer.
Basically, the buffer does not "exist", until time passes, and it grows, as time passes.
So after X min of feed in, it has only fed out X * 0.9995 of the stream. The speed of the program feed from a viewers perspective, in terms of the fact they are not actually watching it at 100% speed, is too small to notice. But over minutes, hours, etc, it adds up to a decent buffer, to where the live vs program can be minutes or more apart.
I believe livestream has a free option. Also youtube offers streaming now. I would not be surprised if they have this also built in.
Hope this helps.