simplesi
Posts: 2327
Joined: Fri Feb 24, 2012 6:19 pm
Location: Euxton, Lancashire, UK
Contact: Website

Project idea: RPi as slingbox type server

Thu Aug 23, 2012 1:37 pm

Lots of projects around to use RPi as a media playback device but how about one to go the other way and take a video feed in via a cheap USB A/V capture device and create a media stream a la slingbox (but just on LAN to start :) )

Just in case someone fancies a challenge :)

Simon
Seeking help with Scratch and I/O stuff for Primary age children
http://cymplecy.wordpress.com/ @cymplecy on twitter

ghans
Posts: 7883
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany

Re: Project idea: RPi as slingbox type server

Thu Aug 23, 2012 7:22 pm

Yeah ... what a kind of challenge ....
Just scraping the SURFACE of the problem pool here :

http://www.raspberrypi.org/phpBB3/viewt ... =35&t=8321
http://www.raspberrypi.org/phpBB3/viewt ... 61&t=10122

Not to foreget that USB is currently unreliable and a resource hog ...


ghans
• Don't like the board ? Missing features ? Change to the prosilver theme ! You can find it in your settings.
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org

guppy
Posts: 3
Joined: Fri Jul 20, 2012 8:37 pm

Re: Project idea: RPi as slingbox type server

Thu Aug 23, 2012 10:13 pm

simplesi wrote:Lots of projects around to use RPi as a media playback device but how about one to go the other way and take a video feed in via a cheap USB A/V capture device and create a media stream a la slingbox (but just on LAN to start :) )

Just in case someone fancies a challenge :)

Simon
Sounds like your looking for TVHeadend.
Here is some people's efforts to get it running on the pi https://www.lonelycoder.com/redmine/issues/1018

Best of luck :)

simplesi
Posts: 2327
Joined: Fri Feb 24, 2012 6:19 pm
Location: Euxton, Lancashire, UK
Contact: Website

Re: Project idea: RPi as slingbox type server

Thu Aug 23, 2012 10:35 pm

nah - nothing so complicated :0
Straight SD analogue video in - xvid/h264/mjpeg/whatever works out :)
Nothing to it - as long as you can get the a/v in in the first place - the rest is just decoration :)
I know there are people out there just looking for a little project to code up over the bank holiday (UK) :)

Simon
Seeking help with Scratch and I/O stuff for Primary age children
http://cymplecy.wordpress.com/ @cymplecy on twitter

ghans
Posts: 7883
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany

Re: Project idea: RPi as slingbox type server

Fri Aug 24, 2012 5:50 am

Without optimization in assembly or finally making use of the GPU APIs you'll
only get to stream a slideshow.
I suppose a bank holiday won't be enough.


ghans
• Don't like the board ? Missing features ? Change to the prosilver theme ! You can find it in your settings.
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org

simplesi
Posts: 2327
Joined: Fri Feb 24, 2012 6:19 pm
Location: Euxton, Lancashire, UK
Contact: Website

Re: Project idea: RPi as slingbox type server

Fri Aug 24, 2012 8:05 am

A slideshow with audio would be a reasonable start :)

Simon
Seeking help with Scratch and I/O stuff for Primary age children
http://cymplecy.wordpress.com/ @cymplecy on twitter

ghans
Posts: 7883
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany

Re: Project idea: RPi as slingbox type server

Fri Aug 24, 2012 12:37 pm

I think you try to make VLC do that.
Just check if there already is V4L support , or recompile the kernel.
And of course you can use ffmpeg/ffserver.

ghans
• Don't like the board ? Missing features ? Change to the prosilver theme ! You can find it in your settings.
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org

simplesi
Posts: 2327
Joined: Fri Feb 24, 2012 6:19 pm
Location: Euxton, Lancashire, UK
Contact: Website

Re: Project idea: RPi as slingbox type server

Fri Aug 24, 2012 5:25 pm

Em - maybe todays codec announcements might make this a bit more viable :)

Simon
Seeking help with Scratch and I/O stuff for Primary age children
http://cymplecy.wordpress.com/ @cymplecy on twitter

ghans
Posts: 7883
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany

Re: Project idea: RPi as slingbox type server

Fri Aug 24, 2012 5:35 pm

Now I will rule the World ! My Pi and my NAS , unite !
World , you may tremble in fear !
MWAHAHAHA !

I seriously need to cool down...
Whew . I never thought this would happen so soon.

ghans
• Don't like the board ? Missing features ? Change to the prosilver theme ! You can find it in your settings.
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org

User avatar
fbutler
Posts: 302
Joined: Thu Mar 15, 2012 4:09 pm
Location: Surrey, England

Re: Project idea: RPi as slingbox type server

Fri Aug 24, 2012 6:25 pm

Has anyone got an Ezcap 116 USB capture device with em28xx drivers working successfully on the Pi yet? I can get audio through it sucessfully , but so far I haven't been able to get any video. I just get a green screen.

simplesi
Posts: 2327
Joined: Fri Feb 24, 2012 6:19 pm
Location: Euxton, Lancashire, UK
Contact: Website

Re: Project idea: RPi as slingbox type server

Sat Aug 25, 2012 12:41 pm

I think this is big issue - getting a capture device to work!
Simon
Seeking help with Scratch and I/O stuff for Primary age children
http://cymplecy.wordpress.com/ @cymplecy on twitter

User avatar
fbutler
Posts: 302
Joined: Thu Mar 15, 2012 4:09 pm
Location: Surrey, England

Re: Project idea: RPi as slingbox type server

Sat Aug 25, 2012 3:22 pm

simplesi wrote:I know there are people out there just looking for a little project to code up over the bank holiday (UK) :)
Simon
Not, quite code yet ;) , but as it's a typical bank holiday and it's pouring down outside, here's some quick thoughts on what the major components of a Sling-Pi architecture could look like:

http://www.trans-omni.co.uk/pi/Sling-Pi.png

Subject to how well the transcoding would work with the new MPEG2 and H.264 GPU codec support, I believe that the next major challenge would be finding a cheap USB video capture adapter that works with the Pi. There has to be one out there, doesn't there? :shock:

72 hours feels like a very long time now :D

simplesi
Posts: 2327
Joined: Fri Feb 24, 2012 6:19 pm
Location: Euxton, Lancashire, UK
Contact: Website

Re: Project idea: RPi as slingbox type server

Sat Aug 25, 2012 3:38 pm

Nice diagram :)
I wasn't really worried about the remote control side but if we are going to emulate the Slingplayer then obviosuly if should and spookily, last summer I built an arduino infra-red tv remote transcoder to let me use my Sky+ remote to contro my blu-ray player so I actually might be able to do that easy bit of it - leave that one to me :)

Simon
PS I don't think we'll get away with Sling-Pi for the project name though!
Seeking help with Scratch and I/O stuff for Primary age children
http://cymplecy.wordpress.com/ @cymplecy on twitter

User avatar
fbutler
Posts: 302
Joined: Thu Mar 15, 2012 4:09 pm
Location: Surrey, England

Re: Project idea: RPi as slingbox type server

Sat Aug 25, 2012 3:57 pm

simplesi wrote: PS I don't think we'll get away with Sling-Pi for the project name though!
Pi-Remote-TV it is then :) http://www.trans-omni.co.uk/pi/Pi-Remote-TV.png

simplesi
Posts: 2327
Joined: Fri Feb 24, 2012 6:19 pm
Location: Euxton, Lancashire, UK
Contact: Website

Re: Project idea: RPi as slingbox type server

Sat Aug 25, 2012 4:04 pm

Hey what about this for way forward while waiting for the proper a/v input - use a web-cam as the input and get the rest coded up :)

Simon
Seeking help with Scratch and I/O stuff for Primary age children
http://cymplecy.wordpress.com/ @cymplecy on twitter

User avatar
fbutler
Posts: 302
Joined: Thu Mar 15, 2012 4:09 pm
Location: Surrey, England

Re: Project idea: RPi as slingbox type server

Sat Aug 25, 2012 4:45 pm

simplesi wrote:Hey what about this for way forward while waiting for the proper a/v input - use a web-cam as the input and get the rest coded up :)

Simon
Yeah, that's exactly what I have been doing with a Logitech C910 webcam, however the frame overruns on capture kills it. So ready on that part when I get my MPEG2 license. I've also been using a Flirc IR receiver with a harmony remote for XBMC on the Pi and that works well. :)

danversj
Posts: 14
Joined: Sat Jul 06, 2013 2:53 am

Re: Project idea: RPi as slingbox type server

Sat Jul 06, 2013 3:24 am

I've just done a proof-of-concept of the transcoding of an MPEG2 DVB TV stream into H264 and viewed it over the internet.

On my home network I have a tvheadend server (not on a raspberry pi but I understand that is possible). With tvheadend you can access any DVB stream as an http source:
e.g. in VLC use a similar url to this as a source:

Code: Select all

http://tvheadend:tvheadend@192.168.1.1:9981/stream/channelid/8
This will display "channel 8" from your tvheadend server. In this example, my tvheadend server is 192.168.1.1.
Tvheadend seems to want a username and password to access the streams.

I'm just a beginner with gstreamer, but here's what worked for me - gstreamer is able to access the tvheadend streams

I run this on my raspberry pi which is on the same network as my tvheadend server. My tvheadend server is 192.168.1.1, my raspberry pi is 192.168.1.21.

Code: Select all

sudo gst-launch-1.0 souphttpsrc location="http://tvheadend:tvheadend@192.168.1.1:9981/stream/channelid/8" ! decodebin ! queue ! videoconvert ! omxh264enc ! mpegtsmux ! tcpserversink host=192.168.1.21 port=5000 sync=false
The raspberry pi is now transcoding the MPEG2 stream to h264, as a TCP stream on port 5000. I can view this stream on VLC with this url:

Code: Select all

tcp://192.168.1.21:5000
I can even port-forward and/or tunnel the raspberry pi's port 5000 across the internet and view this stream anywhere else.

salvob
Posts: 5
Joined: Sat Jul 06, 2013 7:20 pm

Re: Project idea: RPi as slingbox type server

Tue Jul 16, 2013 8:55 am

Hi,

i have tried it,

Code: Select all

./gst-launch-1.0 souphttpsrc location="http://192.168.1.99:31339" ! decodebin ! queue ! videoconvert ! omxh264enc ! mpegtsmux ! filesink location=test.h264
Work very well, i can watch video with vlc player.

Code: Select all

./gst-launch-1.0 souphttpsrc location="http://192.168.1.99:31339" ! decodebin ! queue ! videoconvert ! omxh264enc ! mpegtsmux ! tcpserversink host=192.168.1.200 port=5000 sync=true
vlc : no video
ffmpeg: tcp://192.168.1.200:5000: could not find codec parameters

why?

danversj
Posts: 14
Joined: Sat Jul 06, 2013 2:53 am

Re: Project idea: RPi as slingbox type server

Tue Jul 16, 2013 11:13 am

I'd probably need a bit more info about your setup to really help. with gstreamer, try "sync=false" at the end of the pipeline. with ffmpeg, I'm not 100% sure it will accept a tcp:// url as a source (input).

salvob
Posts: 5
Joined: Sat Jul 06, 2013 7:20 pm

Re: Project idea: RPi as slingbox type server

Tue Jul 16, 2013 12:49 pm

I have tried with sync=false, but it didn't work

Vlc connects, but it doesn't show the video.


These are the latest "ffmpeg -i tcp://192.168.1.200:5000" logs before sending kill signal:

Code: Select all

[mpegts @ 0xa50cfa0] Invalid timestamps stream=0, pts=333980777, dts=333984377, size=530
[h264 @ 0xa510c80] non-existing PPS referenced
[h264 @ 0xa510c80] non-existing PPS 0 referenced
[h264 @ 0xa510c80] decode_slice_header error
[h264 @ 0xa510c80] no frame!
[h264 @ 0xa510c80] non-existing PPS referenced
[h264 @ 0xa510c80] non-existing PPS 0 referenced
[h264 @ 0xa510c80] decode_slice_header error
[h264 @ 0xa510c80] no frame!
^CInvalid timestamps stream=0, pts=333987977, dts=333995177, size=695
[h264 @ 0xa510c80] non-existing PPS referenced
[h264 @ 0xa510c80] non-existing PPS 0 referenced
[h264 @ 0xa510c80] decode_slice_header error
[h264 @ 0xa510c80] no frame!
[mpegts @ 0xa50cfa0] decoding for stream 0 failed
[mpegts @ 0xa50cfa0] Could not find codec parameters for stream 0 (Video: h264 (HDMV / 0x564D4448)): unspecified size
Consider increasing the value for the 'analyzeduration' and 'probesize' options
[mpegts @ 0xa50cfa0] Estimating duration from bitrate, this may be inaccurate
tcp://192.168.1.200:5000: could not find codec parameters

danversj
Posts: 14
Joined: Sat Jul 06, 2013 2:53 am

Re: Project idea: RPi as slingbox type server

Wed Jul 17, 2013 10:45 am

I was getting similar issues when I specified "sync=true". With "sync=false" things started to work. It looks like there's metadata coming though but no actual payload.

The only other thing I could suggest is to try streaming a file out to tcp - such as:

Code: Select all

./gst-launch-1.0 filesrc location=test.h264 ! decodebin ! queue ! videoconvert ! omxh264enc ! mpegtsmux ! tcpserversink host=192.168.1.200 port=5000 sync=false
Also, if you know the dimensions of your source video, try specifying them in the pipeline - vlc may not be getting the width and height parameters.

salvob
Posts: 5
Joined: Sat Jul 06, 2013 7:20 pm

Re: Project idea: RPi as slingbox type server

Thu Jul 18, 2013 7:32 am

Code: Select all

./gst-launch-1.0 filesrc location=test.h264 ! decodebin ! queue ! videoconvert ! omxh264enc ! mpegtsmux ! tcpserversink host=192.168.1.200 port=5000 sync=false
it didn't work.

Code: Select all

./gst-launch-1.0 souphttpsrc location="http://192.168.1.99:31339"  ! tcpserversink host=192.168.1.200 port=5000 sync=false
it works.

Code: Select all

./gst-launch-1.0 filesrc location=test.mpeg  ! decodebin !  tcpserversink host=192.168.1.200 port=5000 sync=false
it didn't work.


how do I specify the size of the video in the pipeline?

dream099
Posts: 1
Joined: Sat Sep 14, 2013 9:30 pm

Re: Project idea: RPi as slingbox type server

Sat Sep 14, 2013 10:06 pm

Salvob, have you solved the problem? I got the same issue when i try to encode a mpegts-stream from my dreambox. No pitcure with vlc when i connect to the pi but the stream seems to work becuase i can see that vlc is recieving bits. If i skip the encode and only stream i got picture.

gibbsjoh
Posts: 1
Joined: Thu Oct 17, 2013 6:29 pm

Re: Project idea: RPi as slingbox type server

Wed Nov 13, 2013 8:28 pm

Hi all,

This is exactly what I've been looking to do since TVCatchup started hemmorhaging channels.

Thanks to the info here and a bit of googling I've got the RPi conencted to a WinTV Nova T (DVB-T stick) with tvheadend and can stream channels to vlc at a bitrate of my choosing with this code:

Code: Select all

sudo gst-launch-1.0 souphttpsrc location="http://172.16.1.41:9981/stream/channelid/18" is-live=true ! decodebin name=demux demux. ! queue ! audioresample ! audioconvert dithering=0 ! "audio/x-raw,channels=1" ! voaacenc ! mux. matroskamux name=mux streamable=true ! tcpserversink host=172.16.1.41 port=5000 demux. ! queue ! videoconvert ! omxh264enc target-bitrate=750000 control-rate=variable ! "video/x-h264,profile=high" ! h264parse ! mux. 
So I've got the bitrate low because my plan is to be able to use this over 3G (and thanks to Virgin Media I have "only" a 3mbit uplink).

I used the aac codec for audio as (anecdotally) passing the Freeview audio stream raw seemed to result in a higher overall bitrate. I was going to use lamemp3enc but this seemed (again anecdotally) seemed to make the video break up a bit.

I had issues like others seem to have had with VLC playing the stream. Using tcp:// rather than http:// when opening the stream worked for me, on Mac OS X, Linux and iOS. I do have an issue with having to start VLC before gstreamer gets too far otherwise it seems not to start.

This seems to be a very exciting project - hopefully y'all with more web/php/gstreamer/etc experience that me are as excited as I am :). My next step is to build a primitive php (or something) script so I can start/stop the stream per channel and hand off to VLC via a web interface. Happy to do testing if anyone else is working on similar.

Cheers
John

macey
Posts: 58
Joined: Thu May 24, 2012 6:05 pm

Re: Project idea: RPi as slingbox type server

Sat May 10, 2014 11:14 am

@gibbsjoh
Have you made any further progress with this (your last post)?
I am using a tailored version of your code/parameters:-

Code: Select all

sudo gst-launch-1.0 souphttpsrc location="http://userid:password@localhost:9981/stream/channelid/72" is-live=true ! decodebin name=demux demux. ! queue ! audioresample ! audioconvert dithering=0 ! "audio/x-raw,channels=1" ! voaacenc ! mux. matroskamux name=mux streamable=true ! tcpserversink host=localhost port=5000 demux. ! queue ! videoconvert ! omxh264enc target-bitrate=750000 control-rate=variable ! "video/x-h264,profile=high" ! h264parse ! mux
to stream over internet, This works in principle (only tried over local wifi network) but has dropped audio & video frames and also sync issues. I wondered if anyone here has improved on this...
edit I am using vlc tcp://localhost:5000

Return to “Advanced users”