Converting your multicast IPTV Freeview to HTTP unicast using udpxy

So, by now you’ve read my previous guides about streaming Freeview/DVB-T channels to your network using VLC and dvblast:

  1. The Angry Technician’s Guide to streaming Freeview via VLC, you Idiots
  2. How to stream EVERY channel from Freeview onto your network
  3. How to stream Freeview HD (DVB-T2) over multicast using dvblast, you Idiots

If you haven’t, you are slacking a bit, as they’ve been up for a while and are the top 3 posts ever on here by pageviews. According to the WordPress.com stats, #2 has been viewed more than 33,000 times, which is frankly a ridiculous number.

Anyway, after all that reading, you might be thinking yo yourself “well, multicast streaming is all nice and fancy, but what I want is some good old-fashioned unicast”. It’s a question that has come up a few times, especially as dvblast will only output multicast streams, so if you want multiple channels per tuner, you are stuck with multicast. There are a few reasons this might not suit your needs, however:

  • Not all of your network supports multicast (especially true if you have cheap and nasty edge switches).
  • You want to view the streams on clients that don’t have multicast software available (e.g. smartphones).
  • You want to access the streams from a different network (e.g. streaming from one location to another over the Internet or a WAN/VPN).

Well, you are in luck. There is another bit of totally free open-source software that will make that conversion for you.

udpxy

udpxy is a piece of software that can site on your network (either on the same box as dvblast or any other Linux client tat can see the streams) that will convert the RTP multicast stream to HTTP unicast.

Like dvblast, it’s very small with low CPU and memory usage, and it doesn’t do any transcoding: all it does is strip the RTP headers and spit out the MPEG transport stream over HTTP. This means it won’t le you view the stream with something like Windows Media Player, but it does open up the options to some software that doesn’t support multicast.

Step 1: Download and compile

There are no packages for udpxy (yet), so download the source to your Linux box and extract it like so:

tar -xzvf udpxy.1.0.23-0-prod.tar.gz

Now change directory into the new udpxy-1.0.23-0 directory and compile & install the software like so:

sudo make install

This will install two new programs into /usr/local/binudpxy and udpxrec. I’m only dealing with udpxy here, but feel free to run udpxrec later with no parameters and have a play.

Step 2: Run udpxy

Unless you have an unusual setup with more than 1 network card, all you should need to do now is start udpxy running with a port of your choosing. I use port 4022 since it’s used in the examples when you run udpxy without any parameters, and ports above 1024 don’t require any special permissions:

udpxy -p 4022

There are more configuration options available: run udpxy with no parameters for a list.

Now, if all is well, you should be able to browse to the following address in your browser

http://192.168.1.1:4022/status

If it’s working, you should see something like this (click to enlarge):

Step 3: Tuning in

If you’ve paid attention to the above status screen, you should already be able to tell how to tune in. In my example setup, I can open the following in VLC:

http://192.168.1.1:4022/rtp/239.255.1.1:5044

This will start receiving an RTP multicast stream from 239.255.1.1 on port 5004 (which is BBC One in my setup) and will relay it over HTTP.

Step 4: Schedule udpxy to start automatically

As per my previous guides, here is an upstart script to start udpxy when the machine boots and the network card (eth0) comes up:

# dvb-udpxy
#

description     "DVB streaming, UDPXY Proxy"

start on net-device-up IFACE=eth0
stop on net-device-down IFACE=eth0

exec udpxy -T -p 4022 -c 50

I’ve added the -c 50 here to change the maximum number of supported clients to 50 (the default is 3). You will need a gigabit ethernet card if you hope to support even nearly this many clients, and I haven’t tested it under load yet, so don’t come crying to me if it all goes wrong.

Step 5: Do something interesting

For testing I was just opening the stream in VLC, but I can do that with the multicast stream. What about something that couldn’t pick up the multicast stream? Say, my Android smartphone?

BBC News running on an HTC One X on Android 4.0.3 ICS

Note to self: clean my screen more often

It’s worth noting that my HTC One X is fairly new and a higher spec than a lot of current phones, and while it runs SD streams with no problems, HD streams are too much for it, so your results may vary. I also needed some additional software as the included video player couldn’t decode MPEG/TS. I tested a few free ones but they all had audio sync problems, so I sprang for VPlayer in the end, which works perfectly. On iOS devices, the AnyPlayerAD app works quite well. Update: As of January 2014, I would recommend VLC on iOS, or GoodPlayer for Android (which has both an ad-supported and a paid Pro version). VLC on Android also worked for me, but is an early beta so no UPnP support (see below).

If your outgoing bandwidth will handle it, you could also forward a port from your router to the internal Linux box and watch over the Internet. Note that there is no authentication involved, so I wouldn’t recommend leaving it configured this way for any long amount of time. A more sensible approach to remote viewing would be to use a VPN.

Step 6: Advertising the feeds

You won’t be able to use SAP announcements for the HTTP streams as SAP is specifically designed to advertise multicast streams. You could distribute the stream URLs via an internal webpage (though you may have to copy the links via a long-press and paste into the app), or you could install the MediaTomb UPnP server on your Linux box to advertise the streams as External URLs.

I’m not going to go into this in detail, but it’s not as hard as the documentation makes it seem (especially if you install it on Ubuntu via Synaptic), and frankly, I’m not doing all your work for you. One hint I will give you is that for some devices (e.g. iOS running AnyPlayerAD), you’ll need to add a fake /stream.mpg suffix to the end of the stream URL to get your player software to recognise the stream correctly. udpxy will ignore the suffix, so it will still play just fine.

…and finally

I’ve recently been directed to the MuMuDVB package which is based on dvblast and attempts to automate some/all of the setup of my DVB streaming guides (including this one). I haven’t tested it myself but it is reported to work well. You’ll still need to do some work if you want to be picky about your channels, so it’s still not completely a point-and-click setup.

Tags: , , , ,

About The Angry Technician

The Angry Technician is an experienced IT professional in the UK education sector. Normally found in various states of annoyance on his blog. All views are those of his imaginary pet dog, Howard.

19 responses to “Converting your multicast IPTV Freeview to HTTP unicast using udpxy”

  1. Dave says :

    Brilliant Stuff!!!!
    Will be on this tonight, thanks for the guide, will this be able to transcode the stream into anything other than mpeg2 as im using a raspberry pi for my front end, i can currently broadcast externally using vlc on http with transcoding h.264 with good results but obviously one instance of vlc per channel, so was hoping to use the dvblast method to get the stream externally.

    But seriously great work :-)

  2. Matt says :

    Had errors following install instructions above.

    This is the output:

    root@mattr-dl:~/Downloads# cd udpxy-1.0.23-0/
    root@mattr-dl:~/Downloads/udpxy-1.0.23-0# make install
    cc -o util/mkdep util/mkdep.c
    -rwxr-xr-x 1 root root 23125 Aug 13 09:51 util/mkdep
    cc -W -Wall -Werror –pedantic -M udpxy.c sloop.c rparse.c util.c prbuf.c ifaddr.c ctx.c mkpg.c rtp.c uopt.c dpkt.c netop.c extrn.c main.c udpxrec.c > udpxy.dep
    cp: cannot stat `udpxy’: No such file or directory
    make: *** [install] Error 1

    Fixed it by doing doing make command first, then make install. So:
    root@mattr-dl:~/Downloads# tar -xzvf udpxy.1.0.23-0-prod.tar.gz
    root@mattr-dl:~/Downloads# cd udpxy-1.0.23-0/
    root@mattr-dl:~/Downloads/udpxy-1.0.23-0# make
    root@mattr-dl:~/Downloads/udpxy-1.0.23-0# make install

    Got this from: http://tinyurl.com/udpxyfix

  3. Dave says :

    Any ideas to why udpxy is not working??
    I have installed to the letter to the above guide. i open a new terminal and “udpxy -p 4022” hit return and
    server@Server:~$ udpxy -p 4022
    server@Server:~$

    When i try to check the status of the port in browser i get no connection, tried opening a stream on another machine and no joy.

    The one only thing that differs from your guide is that my router is 192.168.0.1 instead of the 1.1.- Does that make any difference?

    Thks

    • The Angry Technician says :

      Try running udpxy with the -v flag to get some error messages out of it. It is deceptively quiet otherwise, even when it fails.

      • Dave says :

        Hi there, i tried udpxy -p 4022 -v and got an error stating the port was already in use, so i tried a different port 2222 and got this;

        server@Server:~$ udpxy -p 2222 -v
        2012-09-12 12:21:16.312383 BST S(3752) udpxy 1.0-23.0 (prod) standard [Linux 3.2.0-23-generic x86_64]: udpxy -p 2222 -v
        2012-09-12 12:21:16.312413 BST S(3752) Server is starting up, max clients = [3]
        2012-09-12 12:21:16.312436 BST S(3752) Setting up listener for [0.0.0.0:2222]
        2012-09-12 12:21:16.312456 BST S(3752) Setting low watermark for server socket [6] to [10]
        2012-09-12 12:21:16.312476 BST S(3752) Created server socket=[6], backlog=[16]
        2012-09-12 12:21:16.312492 BST S(3752) Entering server loop [pselect(2)]
        2012-09-12 12:21:16.312501 BST S(3752) Waiting for input from [2] fd’s, NO timeout

        • The Angry Technician says :

          That’s normal operation: you should now be able to connect to http://server:2222/status and get a response

          • Dave says :

            Yep already done it and is working brilliant.

            For a connecting across the Internet from another machine with vlc can you give an example of the network address to be used?
            I tried a couple of things and got a login for null but no luck. Would it be http:-//public ip:forwarded port/udpxy ip:port/rtp/stream ip:port ??

            Thanks

            • The Angry Technician says :

              All you should have to do is substitute the internal servername and port for the external hostname and forwarded port. You do not need to reference the internal server namer or IP at all, only the multicast IP.

            • Dave says :

              Yea tried that but get nothing but error. I’ve forwarded 4 different ports. Same result each time

  4. fred says :

    hi, angry technician! I love your work! I’m using mumudvb with unicast works very well in the lan, but why is it so choppy over the internet? even only radio stations are choppy. I can’t figure it out..

  5. Munene says :

    Hi guys. Am a technician based in Nairobi Kenya. Am seeking info on upgrading of dvb/T to dvb/T2.any information?

    • The Angry Technician says :

      Not sure what you’re after exactly, but you will almost certainly need new hardware. DVB-T tuners cannot pickup DVB-T2 transmissions, so unless your tuner already supports DVB-T2, you’ll need to spend money.

  6. MKS says :

    Hi, thanks for a very good tutorial. I’m using udpxy to take IPTV steams and the plan is to play them on my Samsung SmartTV using the MediaTomb UPnP. I know that the TV can play MPEG TS steam (I have recorded the stream with VLC and played the file on the TV).
    My problem is that my TV doesn’t like the mediatomb url, I get unsupported file type blabla.

    Which mime type did you use in mediatomb to get the playback working on your devices?

    • The Angry Technician says :

      I got the most reliable results with a MIME type of video/ts, and (crucially) by adding a superfluous filename to the end of the stream URL as detailed above, e.g.

      http://dvb.angrytech.internal:4022/rtp/239.255.0.1:5004/stream.mpg

      You could also give video/mpeg a try and see if its any happier with that. The only smart TV I’ve tested is a LG, and that worked with the above config.

  7. Jefferson says :

    Anyone have any idea how to use the android udpxy, and he starting automatically?

  8. sefika says :

    Works great! the dvb-t setup and the UDP proxy.
    Is there a way to make unicast via UDP just like a link and port
    example: udp://192.168.1.1:1234 ??
    Regards

    • The Angry Technician says :

      Some specialist network hardware can do this (Ruckus and Meraki wireless, for example, can do multicast to unicast conversion), but there’s no way of doing it in software that I know of.

  9. Joel Kåberg says :

    Sweet article. Was wondering if you know of any tool that scans a local network for multicast streams?