14

I'd like to stream video from the camera on an iOS device to a receiver via wifi, in effect turning the device into a wireless webcam. Is there a way to build a small app that captures video input on an iOS app and sends it via an RTSP stream or similar?

As this is an ad hoc experiment, I'm not concerned about App Store guidelines and can jailbreak if necessary.

Simon Cave
  • 3,971
  • 4
  • 24
  • 28

2 Answers2

3

If I interpret your question correctly you more or less need to solve four problems:

  1. Get the camera feed.
  2. Convert/encode this to the right format.
  3. Stream the data.
  4. Prevent the phone from locking itself and going into deep sleep.

The first one is fairly simple and Apple has as always provided good documentation and examples -> API link. Make sure you check out their example in the end as you will get a CMSampleBufferRef data object back.

For the second and third part, you should check out the CFNetwork framework and specially CFFTPStream for streaming using FTP.

If your are only building this for yourself then you can always turn off the Auto-Lock feature in the settings. If you on the other hand would like to distribute this to other users you could use a trick to play a mute sound every 10 seconds. This is more or less how all the alarm clocks work in the App Store. Here's a tutorial. =)

I hope I helped a little bit at least. Good luck and best regards!

ABeanSits
  • 1,725
  • 1
  • 17
  • 34
  • This is almost exactly the approach I ended up with. This will not be on the app store so no mute tricks required. I stumbled upon the AVFoundation apis you're referring to. In addition to your steps, I also need to receive the samples in a Mac app then push them into a video stream in such a way that the video is available as an input in applications like iChat. – Simon Cave Mar 28 '11 at 05:46
  • By the way, my intention here is to strap the device onto a remote control car and use the camera for the driver's view, potentially streaming it out to somebody controlling the car remotely via the Internet. Should be a really fun project when I get the time to try it out. – Simon Cave Mar 28 '11 at 05:51
  • Wow, that is a really cool project you got going there. Though I don't know if I would like to be in the car in the opposite lane. ;) You should realy post the code on GitHub or similar. – ABeanSits Mar 29 '11 at 20:33
3

I'm 70% of the way to doing the same thing. Here's how I did it:

  1. Capture content from video input
  2. Chop video into files for use in HTML Live Streaming.
  3. Spin up a web server on the iPhone and make the video files available.
  4. Connect to the IP address of the phone and viola! you've got live streaming video.

Last time I touched the code I was trying to debug my Live Streaming not working. I'll try and get my source code posted on github this weekend, if you'd like to take a look.

kubi
  • 48,104
  • 19
  • 94
  • 118
  • Thanks for the answer, kubi. As your solution uses HTTP streaming the latency incurred is a little too high for my purposes, but this is a *really* interesting idea. Sounds like something that might find an audience on the app store. I'd love to know if you succeed with getting it to work. – Simon Cave Mar 28 '11 at 05:42
  • 1
    Did you every get this working? If so, do you have the code available on GitHub or elsewhere? – golmschenk Mar 05 '13 at 04:16
  • Nope, moved on to other projects and never came back to this. – kubi Mar 05 '13 at 20:29