This "How To" recipe builds a transcoder to process live multicast streams into live and on-demand streams suitable for iPhone and similar devices.
This single-stream example uses a multicast transport stream containing MPEG-2, but could easily use a multicast or unicast stream in a different format. This example runs on Xserve and MacPro machines, it's a requirement that mediastreamsegmenter runs on OS X.
Warning: Reticulation of broadcast TV services requires the permission of the broadcaster.
Thanks to ANU for the opportunity to test this on a multicast-rich network.

Live BBC stream on iPhone via HTTP at 750Kbps
The Result
One live MPEG-2 transport stream transcoded to be visible on the iPhone. VLC (and x264) transcode the stream to the required format for mediastreamsegmenter, which then saves the stream on disk under the webserver. It continually updates the index file so viewers can keep up. Depending on the content, the bitrate of the stream can be 500-900Kbps.
Web page on iPhone with text links to .m3u8 index file

Viewing the stream in the iPhone simulator

Screen shot of iPhone movieplayer without controls overlaid

A mid-range server can transcode three standard-definition 720×576 MPEG-2 services.
Required Parts
- A live MPEG-2 TV service
- The VLC application from www.videolan.org
- The mediastreamsegmenter program, free from Apple's Developer Connect
Documentation
mediastreamsegmenter Man Page
Apple's HTTP Live Streaming Documentation
Installation
The Apache webserver is running above a directory that will contain the media.
( /Volumes/mydisk/www/abc/ in this example).
The webserver is available to the outside
(http://mywebserver.edu/abc/ in this example)
Apache mime types to be added:
AddType application/x-mpegURL m3u8
AddType video/MP2T ts
VLC is expected to be at /Applications/VLC.app/
mediastreamsegmenter gets installed to /usr/bin/mediastreamsegmenter
Your source stream is playable in VLC.
( udp://@239.224.0.2:1234 in this example)
The Script
Save the script below to a text file, say abcstreamer.sh - ensure there are no carriage returns in the command lines. Customise the bold items in the command lines to suit your environment.
#!/bin/sh
rm -rf /Volumes/mydisk/www/abc/*
/Applications/VLC.app/Contents/MacOS/VLC udp://@239.224.0.2:1234 –intf=dummy –sout-transcode-audio-sync –sout='#transcode{vcodec=h264,venc=x264{aud,profile=baseline,level=30,keyint=30,bframes=0,ref=1,nocabac},acodec=mp4a,ab=56,deinterlace}:duplicate{dst=std{access=file,mux=ts,dst=-}}' | mediastreamsegmenter -O -b http://mywebserver.edu/abc/ -f /Volumes/mydisk/www/abc/ -t 10 -s 4 -D
Change permissions for you to execute it
chmod 744 abcstreamer.sh
Run it with
./abcstreamer.sh
The Stream
Watch the directory in the Finder to see the segments arrive. After a while the index file will be written, so you can now get the stream from your iPhone.


Serve It Up
<head><body>
iPhone TV<P><HR><H1><a href="./abc/prog_index.m3u8">ABC</H1><HR><H1><a href="./bbc/prog_index.m3u8">BBC</H1><!-- <video width="320" height="240"><source src="./bbc/prog_index.m3u8" /></video> -->
</body></html>Stats
Tips
- These are by no means optimal settings, please post improvements in the comments.
- Reset VLC's preferences to be sure you don't have any clashing settings.
- Use mediastreamvalidator to debug the transport stream.
- Consider DVBlast or Multicat as additional tools for streaming and routing.
Updates
- Added stats












Sounds great, thanks for the post!
However, I get the following error:
no sout stream module matched “transcodeab=64″
(Mac OS 10.6.2/Intel, VLC 1.0.5)
Any hints?
Daniel
Note that if you leave off the trailing -02.txt from the URL to the Internet-Draft, you will be automatically redirected to the most recent submission.
thanks Roger, that’s fixed. And thanks for a great protocol!
Hi Daniel, that’s odd. Could it be that the VLC command is broken by a linebreak somewhere?
@Daniel, can VLC play the stream by itself?
hello George,
i have 2 Questions
1. do i need to “build” VLC with “DVBlast or Multicat” by myself ?
and if so, what did you use ?
2. Can i use the “normal” SNOW LEOPARD ” version instead of “SERVER” ?
Thanks again
greetings from germany
Hi Marc.
1. No, the VLC app for MacOS X is all you need, no build required.
2. Yes, this will work on Snow Leopard Client. The mime type adjustments still need to be made for the Web Sharing.
Hi Georges
Sounds great yes , I was looking for that from a long time now… but for me, it just do not working
Because, it seems I miss some informations about how to use video source from vlc.( perhaps especially with the formats used by the source – MPEG4 is not enough precise? )
Tested two ways, on my MacBooKPro and/or with a Mac Mini as Server ( all with SL10.6.2/3):
- an USB tuner working very well, with and the plugin for VLC plugin for EyeTV.
It complains about format and many other mysterious parameters…
- selecting an incoming multicast stream in from my TVbox ( Freebox in France) which is legally designed for use VLC to see many well-known international and french TVs channels.
The same happens: it complains about format, or not, but I could never see the directory filling. ( it usually says it is missing some parameters, skipping some frame, and many others terrific errors )
Separating the two elements ( VLC producing the multicast stream on MacBK and receiving it by mediastreamsegneter on the Mac Mini, I could sometimes read some informations but nothing in the sream .TS directory,
Thank for your help and the job already achieved!
Regards
Hi Gérard
I’m not familiar with how to get a USB EyeTV working with VLC but this should still be possible.
Could you post some of the errors you’re getting, and the commands you’re using?
The first step is to get a streaming coming out of VLC to muticast. Check this by running a different copy of VLC to see it plays the transcoded version OK. You can run this second copy of VLC on the same machine as the transcoder, just to be sure that the stream isn’t lost in your network. (Some routers drop multicast unless configured otherwise).
Hello Georges,
I would tell you its working fine now.
I left may ISB Eye TV key away and was already on the same network, but the problem is (as often) dependent form the used source. I can receive the stream from my TVBox now using rtsp: option from VLC subcommand, rather than multicast. And it works. Immediatly i got .ts files filling the remote directory.
As my initial goal was to redistribute a stream coming from a videoconferencing MCU system, towards iPhones, I will keep trying to catch a multicast stream but it seems to become hard as iI cant control and even know the codec parameters used by the MCU. And I think they are responsible for this to work fine or not.
Many thanks again for your help and your site
Hello George,
I’ve tried it and it worked great.
However ,I want to make this work using another web server instead of using Apache , currently I’m trying NanoHTTPD (http://elonen.iki.fi/code/nanohttpd/) since it’s small and easy to embed into my code, it doesn’t seem to work , I can access the ts and m3u8 file via the browser but QuickTime Player and the iPad can’t see the video. I wonder if there’s anything that NanoHTTPD lacks ?
Thank you very much.
Hi Bach,
I think the webserver needs to support HTTP1.1 byte range requests for this to work.
thanks for your kind words,
George
Hi George,
Thanks a lot.
Bach
Hi,
thanks for this great instruction. Unfortunately the VLC command didn’t work for me, but I figured out how to change the syntax, see:
http://jokru.posterous.com/apple-http-live-streaming-to-the-ipadiphone-w
You can also try using the avcstreamer streaming server from http://www.avcstreamer.com . It bundles http live streaming support and works pretty good for an iphone. No web server required and free to download! You can choose a wide range of bandwidth options which will vary the quality for your connection.
thanks Roberto, AVCStreamer looks great.
Hi,
You speak about opening the m3u8 file in QuicktimeX or the iphone, but does it work in Quicktime 7.6.6 or Safari 5 for Win/Mac?
>> not sure about opening the m3u8 file on windows. I think win QT will need updating, but safari might work. Let me know if you try it.
I have a stream encoded with FastVDO encoder, the link I test in Iphone/Ipad is the following:
http://209.51.184.250:1935/EXAFM/udp://209.51.184.250:7178/playlist.m3u8
But I do not see/hear the stream.
Could you please tell me how to modify the link in order to see the stream, please?
Kind regards,
Lovelace
The URL isn’t right. You need to deliver the m3u8 file from a web server. Something like:
http://209.51.184.250:1935/EXAFM/playlist.m3u8
Wish I understood how to do this with a free server via FTP or something, not using crazy scripts in terminal and whatnot. Anyone up for making a video with these same steps on YouTube?!?
Jordan, check out AVCstreamer. It’s got a small price but it’s the convenience of it’s GUI that’s worth it if you want to save time without dealing on the command line.