I\'m working on an app for iOS, where one iPhone has to live stream its camera recordings to another iPhone (to keep things simple, both are in the same Wi-Fi network).
Sounds OK?
Video frames are really big. You're going to have bandwidth problems streaming video from one device to another. You can compress the frames as JPEG
s using UIImageJPEGRepresentation
from a UIImage
, but that's computationally expensive on the "server", and still may not make them small enough to stream well. You can also reduce your frame rate and/or resolution by dropping frames, downsampling the UIImage
s, and fiddling with the settings in your AVCaptureSession
. Alternately, you can send small (5-second) videos, which are hardware-compressed on the server and much easier to handle in bandwidth, but will of course give you a 5-second lag in your stream.
If you can require iOS 7, I'd suggest trying MultipeerConnectivity.framework
. It's not terribly difficult to set up, and I believe it supports multiple clients. Definitely use UDP rather than TCP if you're going to roll your own networking - this is a textbook application for UDP, and it has lower overhead.
Frame by frame, just turn the JPEG
s into UIImage
s and use UIImageView
. There's significant computation involved, but I believe you'll still be limited by bandwidth rather than CPU. If you're sending little videos, you can use MPMoviePlayerController
. There will probably be little glitches between each video as it "prepares" them for playback, which will also result in requiring 5.5 seconds or so to play each 5-second video. I wouldn't recommend using HTTP Live Streaming unless you can get a real server into the mix somewhere. Or you could use an ffmpeg
pipeline -- feed videos in and pop individual frames out -- if you can/want to compile ffmpeg
for iOS.
Let me know if you need clarification on any of these points. It's a lot of work but relatively straightforward.
If you need a solution off the shelf, you may try some ready streaming libraries. The one I have experience is angl streaming lib. Works pretty well with RTMP output to Wowza media server.