Take the 2-minute tour ×

I am the IT guy for a small chain of preschools. Each school current has about 30-40 Axis IP webcams each, ranging from the old Axis 205,206 models, up to the Axis M1011. These cams allow parents to log into a website to view their kid's classrooms throughout the day. The IP cams are on a local network, streaming on port 80. Each school has one public ip address, on which is a reverse-proxy HTTP server. We directly serve the MJPEG from the Axis webcams by basically doing a URL rewrite to allow the client viewing app direct access to the cam via the Axis HTTP API.

This has worked fine for years, and even worked on iPhone, up until recently. In fact, it still works on iPhone, but only when connected Wifi. When the iPhone is connected via 3G, the MJPEG stream no longer works. The carrier is AT&T.

I have done quite a bit of research the past few days, and know that I have to move towards HTTP Live Streaming for Apple devices, so I'm just trying to get my head around the various parts of the puzzle I have to solve to make it work.

My mix of Axis cams may be a problem. The Axis 205 and 206 are MJPEG only, but the M1011 can serve h.264, but apparently only via RTSP. I'm willing to swap out the older Axis cams for the M1011 if that is required or helpful to the overall solution.

From my understanding so far, the first thing I have to sort out is getting my 30 to 40 Axis M1011 h.264 streams (re)encoded / chunked as MPEG-2 (.m3u8 and .ts files).

Question #1

Is it possible and/or feasible to setup one computer, with a "batch" file of VLC command lines, to start and encode 30 to 40 input streams, coming from Axis webcams, into MPEG-2, ready to serve up to iPhone? I'm wondering about the stability, hardware requirements, etc. to handle that many webcams. This same computer would have a HTTP server (probably IIS) and a public IP address, so no need to get the MPEG-2 files any farther than the local computer.

Question #2

For the older Axis models (205, 206) that only serve MJPEG, is is possible to use VLC to encode those to MPEG-2 as well? Am I correct in assuming that (re)encoding or re-packaging .h264 into MPEG-2 is a lot less "work" than encoding MJPEG into MPEG-2, or is it about the same amount of CPU, etc? I have installed the latest version of Videolan and it was easy enough to connect to the Axis M1011 .h264 stream via it's RTSP URL, so I know that much works.

Question #3

Can anyone share any specific VLC command lines or configuration, for either side of my given configuration: Axis M1011 .h264 and/or Axis MJPEG as inputs, and for the output, MPEG-2 (.m3u8 and .ts files), "chunked" into the size as required by Apple iPhone, especially when connected 3G.

Question #4

Finally, if anyone has another suggested approach (different encoder, Media Server that would work better, etc. ) I would like to hear those suggestions as well.

share|improve this question
Could you post some specs. Resolution, bitdepth as well as framerate. –  count0 Sep 11 '12 at 15:12

2 Answers 2

If you have enough network capability to recieve the input stream and enough CPU power and RAM to encode it is possible. There is no inherent limitation otherwise on using a single machine for multiple instances of vlc or ffmpeg.

If you have a camera feeding in 512 kbps input for 30 streams you need 30x512 = 15 Mbps network capability which should be quite fine for a modern machine.

The difficult part is getting 30 transcodes for iPhone output. The output is a MPEG2 TS container but internally it has to have mpeg4 or h.264 encoded content. H.264 encoding is expensive but requires lesser outgoing bandwidth for same quality at MPEG4 [ballpark ~30% less]

Assuming it is ok for you to view a 320x240 which for decent quality with mpeg4 should be decent quality at 256 kbps output. For h.264 you could go to 192 kbps [baseline for 3GS and below]

Trouble now is do you have the horsepower to do the transcoding. Here is how you check

Take one video file representative of your input. Check the input frame rate. Transcode it to the output you need. Check the fps you are getting from ffmpeg for encoding. Notice the multiple of input rate it is at. Remove 5-10% for handling multiple simultaneous streams. that is the maximum you are getting on your machine.

ffmpeg can take input from a http or rtsp source and create an output which is segmented. See this for understanding how to use ffmpeg to create segments. You still need to write a small program to generate the m3u8 files I guess.

It is non trivial here but you will enjoy it. It can be done.

EDIT: Another thing is you only need transcoding to happen when someone is viewing it. So at a given time if someone is not viewing 10 cameras, you dont have to do those transcodings. So perhaps you should first find out statistically how many cameras are viewed at a given time. Look at your history. Then you need a less powerful machine.

EDIT: If you can handle some programming instead of command lines look at: this

share|improve this answer

ffmpeg might be a possible alternative for you. It's command line based, cross platform and you'll be able to control quality, formats as well as stream. The encoding/re-encoding quality basically controls the processing speed of your application, taken the throughput neccessary to grab the data out of the loop.

share|improve this answer
Is running 30 to 40 instances of ffmpeg on the same computer possible? Of course there are alot of variables, but in general, assuming a modern CPU, loads of RAM, whatever.. there is a reasonable expectation that this many cameras would be ok? Perhaps my assumption is wrong - I am assuming there is a 1:1 relationship between an IP cam and ffmpeg (or VLC). When you say "loop", do you mean I can configure 35 IP cams to encode in one instance of ffmpeg, and it will loop accordingly? –  Tim Murphree Sep 11 '12 at 16:02
You can have as many instances as your OS allows, no problem there. You'd have one instance per stream in that case. The parameters are more about quality of encoding (cpu(processing) and throughput(copying the data)) (less bandwidth, lower quality), so you'll have to tweak the system to get your desired tradeoff. I wanted to know some specs before giving any recommendation, but i can say i've been decoding 8 1440x900 + 4 1920x1080 streams progressive (30 fps) in real time on an 8 core xeon flawlessly. –  count0 Sep 11 '12 at 18:17

Your Answer


