skebo3000
Posts: 13
Joined: Tue Nov 05, 2013 7:49 am
Location: Munich

Stream IPTV from one RPi to another RPi

Tue Nov 05, 2013 8:44 am

Hello guys, this forum is probably my last hope for finding a solution to my problem. Any help would be greatly appreciated.

So here goes...

I have been living in Germany for a couple of years now, and I would like to watch an IPTV from my homeland provider. The idea was to setup two raspberries, so that the first one, located in my homeland-LAN (with access to IPTV), would stream IPTV to the second one, located in a remote German-LAN. Thats the general idea.

I have managed to setup the first raspberry (located in my homeland-LAN) to stream IPTV to a laptop located in a remote German-LAN. So far so good. I use vlc on both sides. It works, the CPU load of the streaming raspberry is around 40%, the laptop in a remote LAN receives and displays AV perfectly.

Heres how I do it:

The raspberry in homeland-LAN streams from "udp://@239.10.1.9:5000" to "my.german.ip:1234" with the following command:
vlc udp://@239.10.1.9:5000 :sout=#udp{mux=ts,dst=my.german.ip:1234} :no-sout-rtp-sap :no-sout-standard-sap :ttl=1 :sout-keep

The laptop in a remote German-LAN receives the AV successfully with the following command:
vlc udp://@:1234

Like I said - so far so good. But the idea was ofcourse to have a raspberry instead of laptop in a German-LAN, which would always be connected to a TV, no laptops involved or anything else for that matter.

The problem occurs, when I want to use a raspberry instead of the laptop in the German-LAN. The moment raspberry starts to play from udp://@:1234, the CPU-load goes 99% and it freezes. So up until now I was able to realise, that the stream, sent from the raspberry located in my homeland-LAN is somehow too hard for the raspberry in the German-LAN to decode and display properly.

So finally here is the question: what needs to be done in order for it to work properly?

Many thanks in advance.
Last edited by skebo3000 on Tue Nov 05, 2013 2:21 pm, edited 1 time in total.

gkreidl
Posts: 6093
Joined: Thu Jan 26, 2012 1:07 pm
Location: Germany

Re: Stream IPTV from one RPi to another RPi

Tue Nov 05, 2013 12:58 pm

1) I'm not sure if omxplayer supports udp streams (never tried it). If it does, it should work perfectly. Give it a try.

2) If your video resolution is SD or HD 720p with a not too high bitrate, you could use the HW accelerated version of VLC. You have to compile it yourself. I posted a complete step by step tutorial two days ago.
Minimal Kiosk Browser (kweb)
Slim, fast webkit browser with support for audio+video+playlists+youtube+pdf+download
Optional fullscreen kiosk mode and command interface for embedded applications
Includes omxplayerGUI, an X front end for omxplayer

vadim
Posts: 129
Joined: Wed Sep 18, 2013 1:47 pm
Location: Nottingham

Re: Stream IPTV from one RPi to another RPi

Tue Nov 05, 2013 1:23 pm

You really have to use HW acceleration.
Out of curiosity, how many packets get lost in transborder streaming and what size of packets is default in vlc?

skebo3000
Posts: 13
Joined: Tue Nov 05, 2013 7:49 am
Location: Munich

Re: Stream IPTV from one RPi to another RPi

Tue Nov 05, 2013 1:25 pm

Thank you for your reply guys.

I have tried the omxplayer, without installing anything or changing any settings on my raspi - left everything default as it is on a noobs image. So to summarize what I have tried: the raspi in the homeland-LAN was streaming with vlc to the raspi located in the German-LAN who tried to play the stream with the omxplayer.

The command I used on the German-LAN (receiving site) raspi was:

omxplayer -o hdmi -r udp://@:1234

and it started playing, very jerky / choppy and stopped after some 5-10 seconds. I thought sound was ok. So its not a final solution I guess...

I havent tried your second option yet.
Last edited by skebo3000 on Tue Nov 05, 2013 2:29 pm, edited 2 times in total.

skebo3000
Posts: 13
Joined: Tue Nov 05, 2013 7:49 am
Location: Munich

Re: Stream IPTV from one RPi to another RPi

Tue Nov 05, 2013 1:30 pm

@vadim

Thanks for your reply.

I dont have enough knowledge to answer any of your questions. I dont even know where to set the size of the packages to start with. Nor how to use HW acceleration.

vadim
Posts: 129
Joined: Wed Sep 18, 2013 1:47 pm
Location: Nottingham

Re: Stream IPTV from one RPi to another RPi

Tue Nov 05, 2013 1:38 pm

skebo3000 wrote:@vadim

Thanks for your reply.

I dont have enough knowledge to answer any of your questions. I dont even know where to set the size of the packages to start with. Nor how to use HW acceleration.
In vlc on your laptop in Media Information / Statistics you can see how many frames/audio buffers were dropped in relation to the total. You seemed satisfied with output on the laptop, so that is not the problem with jerky playback on RPi.
Just follow gkreidl's instructions :)

skebo3000
Posts: 13
Joined: Tue Nov 05, 2013 7:49 am
Location: Munich

Re: Stream IPTV from one RPi to another RPi

Tue Nov 05, 2013 1:50 pm

Ok, so we are talking about HW acceleration on the RPi located in the German-LAN (receiving site) and not on the RPi located in the homeland-LAN (sending site), right?

gkreidl
Posts: 6093
Joined: Thu Jan 26, 2012 1:07 pm
Location: Germany

Re: Stream IPTV from one RPi to another RPi

Tue Nov 05, 2013 1:54 pm

skebo3000 wrote:Ok, so we are talking about HW acceleration on the RPi located in the German-LAN (receiving site) and not on the RPi located in the homeland-LAN (sending site), right?
right
Minimal Kiosk Browser (kweb)
Slim, fast webkit browser with support for audio+video+playlists+youtube+pdf+download
Optional fullscreen kiosk mode and command interface for embedded applications
Includes omxplayerGUI, an X front end for omxplayer

skebo3000
Posts: 13
Joined: Tue Nov 05, 2013 7:49 am
Location: Munich

Re: Stream IPTV from one RPi to another RPi

Tue Nov 05, 2013 1:57 pm

Ok thanks guys, ill give it a try tonight and ill let you guys know how it went :D

skebo3000
Posts: 13
Joined: Tue Nov 05, 2013 7:49 am
Location: Munich

Re: Stream IPTV from one RPi to another RPi

Wed Nov 06, 2013 6:59 am

Hi again, I have installed fresh NOOBS image yesterday (v1_3_2), and right after that I compiled the vlc - it took me 3-4 hours... Then I have tried playing the stream.
I have opened the stream with
vlc udp://@:1234
and the video looked better but still choppy... Am I missing something here?

Am I missing some parameters or arguments or something? Should I install something additionally on my RPi or should I install from another image to start with? Or maybe some additional codecs? I really dont know what to do next, any help and guidance would be very appreciated.

Many thanks.

vadim
Posts: 129
Joined: Wed Sep 18, 2013 1:47 pm
Location: Nottingham

Re: Stream IPTV from one RPi to another RPi

Wed Nov 06, 2013 9:27 am

is it worse than on laptop? is Pi connected by cable or Wifi? what is the bitrate and what audio/video streams are transmitted? what is cpu load? how much memory is given to GPU? how large is buffer on vlc? how long is ping from one Pi to another?

skebo3000
Posts: 13
Joined: Tue Nov 05, 2013 7:49 am
Location: Munich

Re: Stream IPTV from one RPi to another RPi

Wed Nov 06, 2013 10:35 am

To answer your questions:

its alot worse then on the laptop
Ping is 47-48 ms
GPU memory is default - I havent touched anything
connected over cable
cpu load max

dont know about other stuff - i use the following command on the server side:
vlc udp://@239.10.1.9:5000 :sout=#udp{mux=ts,dst=my.german.ip:1234} :no-sout-rtp-sap :no-sout-standard-sap :ttl=1 :sout-keep
im guessing that this command means just take whatever comes from udp://@239.10.1.9:5000 and stream it to my.german.ip:1234 - so I dont know anything about bitrate, audio, video and vlc buffer. I know for sure its not 1080p because im not subscribed to any HD-channels. so Id say maybe 720p because picture is pretty good, but as I said - Im not sure.

It would be great if you could point me in the right direction and tell me how to find infos about bitrate, audio, video, buffer etc.

In the meantime I have checked the tutorial that you mentioned: http://intensecode.blogspot.de/2013/10/ ... ation.html, and under step 4 i saw this:

Step 4: how to run it with hardware acceleration enabled from command line:

# ./vlc --vout omxil_vout <other_params_you_might_need>
(Info: you absolutely have to use the param --vout omxil_vout for vlc to use the custom video output for raspberry!)

Does that mean that vlc udp://@:1234 isnt enough? Should it be like vlc --vout omxil_vout udp://@:1234 ??

gkreidl
Posts: 6093
Joined: Thu Jan 26, 2012 1:07 pm
Location: Germany

Re: Stream IPTV from one RPi to another RPi

Wed Nov 06, 2013 11:04 am

If you have followed my tutorial step by step, omxil_vout is used as default video output, so there's no need to set the --vout option (but it doesn't harm either).

Run VLC from the desktop, open the message window, open the stream from the menue, let it run for a moment and stop it with the "s" key. Then have a look at the messages. That might give you a hint.

I have been streaming 720p HD TV across my local network to VLC in the RPi (using http) and it works more or less; I have overclocked to 1000/500 (also core, and h-264). But you MUST disable resampling, because that seems to need too much CPU. I'm still getting 15% idle when displaying the stream, so it's a bit below the RPI's limit. (With omxplayer I get 80% idle time). Bit rate is about 12 - 14 MBit.
Minimal Kiosk Browser (kweb)
Slim, fast webkit browser with support for audio+video+playlists+youtube+pdf+download
Optional fullscreen kiosk mode and command interface for embedded applications
Includes omxplayerGUI, an X front end for omxplayer

skebo3000
Posts: 13
Joined: Tue Nov 05, 2013 7:49 am
Location: Munich

Re: Stream IPTV from one RPi to another RPi

Wed Nov 06, 2013 11:43 am

Ok I'll try that when I get home.

But if you are getting 80% idle with omxplayer, then why use vlc in the first place?

gkreidl
Posts: 6093
Joined: Thu Jan 26, 2012 1:07 pm
Location: Germany

Re: Stream IPTV from one RPi to another RPi

Wed Nov 06, 2013 12:21 pm

skebo3000 wrote:Ok I'll try that when I get home.

But if you are getting 80% idle with omxplayer, then why use vlc in the first place?
I was simply interested how good the HW accelerated version of VLC on the RPi really is. And it has some niceties, that omxplayer misses (very good slow motion or fast replay, for example, and much better keyboard options while playing). And I wanted to know, if I should optionally support VLC from Minimal Kiosk Browser (as an alternative to omxplayer). For now, I have decided against it, but that may change in the future.

For day to day use, I still prefer omxplayer.
Minimal Kiosk Browser (kweb)
Slim, fast webkit browser with support for audio+video+playlists+youtube+pdf+download
Optional fullscreen kiosk mode and command interface for embedded applications
Includes omxplayerGUI, an X front end for omxplayer

skebo3000
Posts: 13
Joined: Tue Nov 05, 2013 7:49 am
Location: Munich

Re: Stream IPTV from one RPi to another RPi

Thu Nov 07, 2013 7:43 am

Yesterday I tried couple of things in order to narrow down the problem. First I increased GPU memory to 128MB.

Then I wanted to know if my RPi in the German-LAN is even capable of playing HD video so I tried playing a movie with omxplayer and vlc.
With omxplayer it ran totaly smooth, with average cpu usage around 10-15%.
With vlc (allegedly with HW acceleration) not so smooth, average cpu usage around 80%.

So the next logical step for me was to focus on the encoding side (homeland-LAN). I must be doing something wrong there.

As I explained in my earlier posts, Im streaming from udp://239.10.1.11:5000 to my.german.ip:1234 with vlc. If I stream the TV-channel as it is, by that I mean I dont encode it with H264 - then the CPU usage of the sending-RPi (located in homeland-LAN) is about 40%. The problem with such not encoded stream is that I can not play it on the RPi in German-LAN. I could only watch it on a laptop (enough CPU power).

So its only logical that I have to encode the stream with H264 on my sending-RPi (homeland-LAN), to be able to play the stream with omxplayer on my RPi in the German-LAN.

When I encode it with vlc like this

vlc udp://@239.10.1.11:5000 :sout=#transcode{vcodec=h264,fps=25,acodec=mpga,ab=128,channels=2,samplerate=44100}:std{access=udp,mux=ts,dst=my.german.ip:1234} :no-sout-rtp-sap :no-sout-standard-sap :ttl=1 :sout-keep

the AV receive on the RPi is very choppy, so theres gotta be something wrong with encoding.
and by the way - even if I encode the stream on an XP machine - the output is choppy.

Any ideas?

vadim
Posts: 129
Joined: Wed Sep 18, 2013 1:47 pm
Location: Nottingham

Re: Stream IPTV from one RPi to another RPi

Thu Nov 07, 2013 11:09 am

Just check the stream that comes from the provider before attempting any unaccelerated transcoding!

gkreidl
Posts: 6093
Joined: Thu Jan 26, 2012 1:07 pm
Location: Germany

Re: Stream IPTV from one RPi to another RPi

Thu Nov 07, 2013 12:34 pm

If the video (and audio) are playing at all, it is not a question the codecs. If you can receive them with your laptop, the internet connection between your two LANs must be fast enough.

You never said something about the source of the TV stream; this must be some kind of local hardware on your home network and I think that must be doing the encoding of the stream (and to a lower bitrate); transferring original HD TV across the internet is not possible, even with VDSL.

I ran some tests yesterday on my local LAN, streaming with VLC (from my desktop machine) to the RPi, receiving the streams with VLC and with omxplayer. Playback was not choppy, but I got artefacts when using UPD. With RTSP and HTTP I got streams with perfect quality. I'm using HTTP video streams all the time on my local network, up to 1080p, and it works like a charm. I only got the artefacts when using udp. So I suggest to try a HTTP stream (using VLC) and receive that with either omxplayer or VLC.
Minimal Kiosk Browser (kweb)
Slim, fast webkit browser with support for audio+video+playlists+youtube+pdf+download
Optional fullscreen kiosk mode and command interface for embedded applications
Includes omxplayerGUI, an X front end for omxplayer

skebo3000
Posts: 13
Joined: Tue Nov 05, 2013 7:49 am
Location: Munich

Re: Stream IPTV from one RPi to another RPi

Fri Nov 08, 2013 8:37 am

Hey guys. I have finally found a solution. Thanks to your guidance I have focused on the source of the TV stream.

I have been using a list of channels to stream them to my laptop in a remote LAN. I have found out that the channels were encoded with some codec that was not x264 - cant remember which one and it doesnt matter. So I went back to where I downloaded the list, hoping I would find another list simillar to this one, that would maybe contain channels encoded with x264. And guess what - there was one. When I compared the lists, I found out the channels I was looking for were just one subnet higher, for example:

239.10.1.11:5000 - a channel encoded with some codec
239.10.2.11:5000 - the same channel encoded with x264

So now it plays fine, there are some glitches now and then, but 99% of the time it plays perfectly well. Maybe the glitches are bandwidth or cpu load related, because I have a torrent and an ftp server on the streaming RPi turned on the whole time.

So Im very grateful for your help guys, thank you!

vadim
Posts: 129
Joined: Wed Sep 18, 2013 1:47 pm
Location: Nottingham

Re: Stream IPTV from one RPi to another RPi

Fri Nov 08, 2013 9:42 am

Enjoy! You will get udp packets disappearing or delayed along the way from time to time. Thus the glitches. Actually I am still eager to know what is the ratio of dropped packets in this setup.

skebo3000
Posts: 13
Joined: Tue Nov 05, 2013 7:49 am
Location: Munich

Re: Stream IPTV from one RPi to another RPi

Fri Nov 08, 2013 9:46 am

Thank you! I will be glad to tell you if you could just tell me how exactly can I see that.

vadim
Posts: 129
Joined: Wed Sep 18, 2013 1:47 pm
Location: Nottingham

Re: Stream IPTV from one RPi to another RPi

Fri Nov 08, 2013 12:06 pm

Ctrl+i -> Statistics (or something similar) during playback on the laptop.

skebo3000
Posts: 13
Joined: Tue Nov 05, 2013 7:49 am
Location: Munich

Re: Stream IPTV from one RPi to another RPi

Sun Nov 10, 2013 11:51 am

Is that what you want to see?
Attachments
stats.PNG
stats.PNG (31.93 KiB) Viewed 9999 times

vadim
Posts: 129
Joined: Wed Sep 18, 2013 1:47 pm
Location: Nottingham

Re: Stream IPTV from one RPi to another RPi

Sun Nov 10, 2013 1:02 pm

yep, thanks. looks like you've got a good uplink at home.

skebo3000
Posts: 13
Joined: Tue Nov 05, 2013 7:49 am
Location: Munich

Re: Stream IPTV from one RPi to another RPi

Sun Nov 10, 2013 3:03 pm

yeah I have 10/10

Return to “Graphics, sound and multimedia”