iPhone Streaming
I’ve finally done it after two long days working with VLC and my Mac and iPhone I finally have a native live video stream to an iPhone.
I started by looking at this site which explained a way to stream to iOS devices using HTTPStreaming and in particular adaptive HTTP Streaming. This tutorial was however out of date, like many I had found either VLC was many version behind the current or the software used to segment the stream no longer existed.
Since version 1.2 (now in version 2.0.1) VLC has been able to create HLS live streams as part of its core streaming functionality, this function though I have found to be poorly documented as it is very similar to the standard progressiveHTTP Streaming module.
Stream Requirements
- A Video or Stream Source
- VLC – dummy or web interface
- A webserver, Apache or similar
You used to also require the mediastreamsegmentator from Apple, however a version of this software has now been written into the core of VLC after the Unwired Developer created a module for VLC back in early 2010 to help streamline the process, this module has since become core functionally of VLC.
The Working VLC Code
The code below is the final code that I used to start VLC into dummy mode from the command line, then transcode and re-stream the incoming stream or video file.
/Applications/VLC.app/Contents/MacOS/VLC -v -I "dummy" rtsp://media-us-2.soundreach.net/slcn_sports.sdp :sout="#transcode{vcodec=h264,vb=512, venc=x264{aud,profile=baseline,level=30,keyint=30,bframes=0,ref=1,nocabac},acodec=mp3,ab=96} :std{access=livehttp{seglen=10,delsegs=true,numsegs=5, index=/Applications/MAMP/htdocs/iPhone/stream.m3u8, index-url=stream-########.ts}, mux=ts{use-key-frames}, dst=/Applications/MAMP/htdocs/iPhone/stream-########.ts"
The first bold item is the incoming stream, for this I used a random RTSP stream I found online for testing, This can be replaced with a file that you wish to stream “as live”, there is also another option in this code to allow “On-Demand” videos to be created like this, but I will go into that another day.
The second bold (index=) item is telling VLC the file path of where it should store the “playlist”, the file that controls the stream, and the one you link to in the video players.
The third bold (index-url=) item is telling it how to link the .ts (Transport Stream) files in relation to the playlist file, in most cases these are stored in the same location, which means I only had to provide the file name of the stream files. The #### signifies a number which is auto generated by VLC with each file.
The fourth and final bold (dst=) item is telling VLC where to store the .ts files and what to call them, this is that system file path, similar to the index= above, including the filename.
On the right you can see the many code variations I went through first to come up with the winning combo above. The above code still needs a few tweaks to find the optimised quality to bit rate, and also a few tweaks to the number of .ts files created. Each .ts file holds approx. 10 seconds of video, and after 5 have been created it deletes the oldest and replaces it with the next 10seconds of footage, this currently allows for 40seconds or so of rewind during a live show.
Distrubution
To distribute HLS or AdaptiveHTTP streams is quite simple, in its simplest form all you require is a web server (Apache, Nginx, IIS) and a webpage with the <video> tag.
Mime Types however are critical and are not set as standard for most web servers, these simple flags are enough to break a stream that is otherwise behaving perfectly. To find out more about mime’s have a look here: http://en.wikipedia.org/wiki/MIME
Configure the following MIME types for HTTP Live Streaming:
File Extension MIME Type .M3U8
application/x-mpegURL
orvnd.apple.mpegURL
.ts
video/MP2T
If your web server is constrained with respect to MIME types, you can serve files ending in
.m3u
with MIME typeaudio/mpegURL
for compatibility.
The above quote came direct from the apple HLS Developers Site here.
For Apache systems its as simple as creating a .htaccess in the site’s folder or editing the main httpd.conf with the following two lines:
AddType application/x-mpegURL .m3u8 AddType video/MP2T .ts
OR
AddType audio/mpegURL .m3u AddType video/MP2T .ts
This then tell’s the client that the file is video and in a mpeg transport stream, which allows it to process it accordingly. Without one of these MIME flags being set, a .m3u8 file is classed as text/plain and all you load is a 10+ line document with reference links, no video.
Also without the MIME type’s being set you can end up with a black screen on the iPhone Safari, the only way to get out of this black screen is to fully exit Safari and then stop it before it loads or Exit Safari and stop the web server, this then forces an error on the iPhone and allows you to navigate the control’s again.
The Web Page
The webpage I used for this test was extremely simple, and included two lots of the <video> tag. The top set was a reference file that can be found on apple developer site, and the bottom one was the stream from my mac.
<html> <head> <title>HTTP Live Streaming Example</title> </head> <body> <video src="http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8" controls></video> <br/> <br/> <br/> <video src="http://10.0.0.3:8080/iPhone/stream.m3u8" controls> </video> </body> </html>
The above code and system works flawlessly on an iOS 5.1.1 and OSx 10.7.3 (Safari 5.1.5).
Ravensbourne 2012
Ravensbourne 2012 is the end of year show run solely by students to show case students work to their respective industries. As for 3D Storytelling my role is as head of rigging and logistics. This has involved working a lot closer to the directors of the event rather than working within the engineering group.
The main task that I have faced with Ravensbourne 2012 has been lighting for the 4th floor. Originally fashion wanted to put there show on level 7 but this would have made lighting it physically impossible due to the height of the ceiling and logistically it wouldn’t be possible to have the number of people that they wanted in that space. Russell and myself talked them round to holding the show on the 4th floor which is a much better space to work in but still has many challenges first of which was designing a light weight structure that was strong enough to take more lights than we had last year. Due to the weight restrictions on the floor I had to put an extra 4 ground supports in to spread the load over the floor. Overall the maximum load that I can put onto the floor is 4 tons but I can’t have more than 500KG at any one point. This has definitely been my biggest engineering challenge this year, if we had been allowed to fly the structure off the RSJ’s on the ceiling above the 4th floor I would have never faced this issue and the space would look a lot cleaner than its going to, but we all have to make compromises.
Working so closely with the management team has posed its own issues as Russell and myself have been rather segregated from the engineering team and been in the level 1 office most of the time, this is something that we had to do however as the event would not run without us. The hours that we have put into this has been tremendous, planning almost everything and trying to fix all of the logistical/engineering problems and picking up the slack when needed. I have also had a couple of run in’s with the management team on some of their decisions, the main one being over stage electric. After 3D Storytelling I did some deals with stage electrics for Ravesbourne 2012 with the managing director of Ravensbourne 2012 but the rest of the management team did not agree and felt that we could get a better deal elsewhere. This was not true as the kit they were asking for from other companies was not what I had specified for the rig. Eventually a very last minute decision was made to go with my original plan, as it was the best deal on the table.
Snake Pit – Take 2
This week we have been a part of Snake Pit, the Easter school held at Ravensbourne for years 10,11,12, and 13 from local schools. For this event we provided a lighting plot and its associated rig, and then left it to be programmed and operated by Martin Higgins. The rig was fairly simple yet another experimentation ground for all involved, the Lighting plot included some extremely new fixtures (Mac AURA’s) as well as some older generation LED and Moving Lights (Chormastrips and Mac 250’s).
The majority of the lighting rig was LED with the back-wall wash, audience and truss being illuminated by LED. Source 4’s provided the the main key and fill lights for the 3 judges with the back light provided by 1k Pup’s, the Mac 250’s provided the key, fill and back light for the contestants as well as effects.
The Christie Projector shown in the photo was not used during the performance and was only on during the rig and de-rig to allow music to be played out of the house system.
3D Storytelling 2012
3D Storytelling is one of the biggest events of the year at Ravensbourne. The event is totally different from any other that is run within Ravensbourne as it is headed up by the events team and is run by a select group of students. This year Russell Fleming and Myself took on all of the events logistics and rigging with Tom Glover creating the lighting design. The event features around the fact that there is a RealD Projector in the walker space that allows speakers from different companies to show off there work to the rest of the 3D television and film industry. This gives the students a platform to network with people form within industry as nearly 1000 delegates turn up across the 2 day event.
My role for 3D storytelling was as head of rigging and logistics, Russell was head of event technology and logistics, both of us have these roles for Ravensbourne 2012. The main rigging requirements for this event were to light the walker space for the keynote speeches, light the building to give it a different look and feel and put power distribution on the 4th floor for the exhibition.
To start with I worked out the power requirements for the exhibition going off a floor plan with 22 stalls on it. This time I decided to use the 125 Amp 3Phase on level 5 and split it down to 2 63 Amp 3Phase’s as we had some high power lights for the architectural lighting. The distro’s that we went with were 125A 3P to 2 x 63A 3P and 2 x 63A 3P to 18 x 16A. This meant that I had more than enough outputs for all of the lighting requirements and if all of the stalls were used. We also made the decision to cut the 4 way extensions down to 2 as it was felt that they only need 2 sockets per stall.
For the lighting side of the rigging Tom had asked for 4 city colour washes to go on level 7 and 4 to go on level 4 along with 2 Clay Paky 1200 spots to go at each location. The Clay Paky’s on level 7 had to be hung to get good coverage on the wall. Originally I wanted to hang them off a truss rigged to the RSJ’s above level 9 but as we did not have a load testing certificate to say what load they could take health and safety did not like the idea. I then decided to put them on 2 wind up stands on the 7th floor. The lighting for the main atrium was originally going to go on the 4th floor but was deemed to be in the fire lane and had to be moved when once it had been put in place. We had to move it to the 1st floor/Mezz which actually created some nicer angles and gave a really nice look on the final night when the networking was taking place in the welcome space. All of these lights were sitting on 3ft high deck so that the metal grill under the railing did not get in the way.
In the walker space we felt that we had to do something different from what had been done before in that space. We ended up dead hanging a scaff bar and putting par cans up for a wash of colour along with source 4’s with gobo break ups in them, for once no movers were used. This all ran of the house dimmer pack saving a lot of money and time.
The biggest challenge that Russell and myself had in the planning stage of this event was where to put a Telegenic OB truck. This is a major problem as the outside of Ravensbourne is not designed to have a truck of this size sitting there for over 2 days. This caused major problems right up until the last minute as every location that we chose there was something causing a problem. In the end we got parked it down the side of Rave. I feel proud at the amount of contacts that Russell and myself made out of this event, some of which involved people that generally students don’t even know about. I also made sure that I did not make the same mistakes that I made at penrose market. The logistics generally ran very smoothly with no major problems. This is due to the time and care that Russell and myself put in and the communication with the management of the event. I have to give a big thank you to the second rigging team as they managed to gel over 250 florescent lights around Rave to change the colour of the building.