or Connect
AVS › AVS Forum › Video Components › Home Theater Computers › HTPC - Linux Chat › Live streaming from an HD-PVR ? (vlc streaming, ffserver, rygen ???)
New Posts  All Forums:Forum Nav:

Live streaming from an HD-PVR ? (vlc streaming, ffserver, rygen ???)

post #1 of 29
Thread Starter 
I'm setting up a whole house AV system. Our house has 2 satellite receivers.

I'd like to connect an HD-PVR to each receiver and stream the outputs so that they can be watched anywhere in the house on a variety of devices via our local network.

I'm running Fedora 19 these days.
$ uname -a
Linux XPS17.localdomain 3.11.6-200.fc19.x86_64 #1 SMP Fri Oct 18 22:34:18 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

Progress thus far.

The HD-PVR device is recognized by the OS and the driver is installed automatically.

I get this in dmesg

usb 2-1.2: new high-speed USB device number 10 using ehci-pci
[25096.604008] usb 2-1.2: New USB device found, idVendor=2040, idProduct=4903
[25096.604013] usb 2-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[25096.604015] usb 2-1.2: Product: Hauppauge HD PVR
[25096.604017] usb 2-1.2: Manufacturer: AMBA
[25096.604018] usb 2-1.2: SerialNumber: 00A5EB14
[25096.622360] hdpvr 2-1.2:1.0: firmware version 0x1e dated Mar 7 2012 08:25:15
[25097.143552] hdpvr 2-1.2:1.0: device now attached to video1

lsmod shows the driver is installed.

$ lsmod | grep hdpvr
hdpvr 32518 0
v4l2_common 15138 1 hdpvr
videodev 132348 4 hdpvr,uvcvideo,v4l2_common,videobuf2_core
i2c_core 34242 5 i2c_i801,hdpvr,nvidia,v4l2_common,videodev


For testing, I started out with this, which creates a file from the HD-PVR output.

cat /dev/video1 > stream.ts


vlc test.ts plays the file correctly and returns the following.

$ vlc stream.ts
VLC media player 2.0.8 Twoflower (revision 2.0.7-29-g12aebf9)
[0x1564108] main libvlc: Running vlc with the default interface. Use 'cvlc' to use vlc without interface.
[0x7f2b78001b78] ts demux error: MPEG-4 descriptor not found
[0x7f2b78cb1dc8] packetizer_mpeg4audio packetizer: AAC channels: 2 samplerate: 48000
Fontconfig warning: FcPattern object size does not accept value "0"
Fontconfig warning: FcPattern object size does not accept value "0"
[h264 @ 0x7f2b78caaaa0] illegal short term buffer state detected
^C

mplayer test.ts plays the file correctly and returns the following.

$ mplayer stream.ts
MPlayer SVN-r36171-4.8.1 (C) 2000-2013 MPlayer Team
mplayer: could not connect to socket
mplayer: No such file or directory
Failed to open LIRC support. You will not be able to use your remote control.

Playing stream.ts.
libavformat version 54.63.104 (external)
TS file format detected.
VIDEO H264(pid=4113) AUDIO AAC(pid=4352) NO SUBS (yet)! PROGRAM N. 1
FPS seems to be: 30.000000
Load subtitles in ./
==========================================================================
Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family
libavcodec version 54.92.100 (external)
Selected video codec: [ffh264] vfm: ffmpeg (FFmpeg H.264)
==========================================================================
==========================================================================
Opening audio decoder: [ffmpeg] FFmpeg/libavcodec audio decoders
AUDIO: 48000 Hz, 2 ch, floatle, 0.0 kbit/0.00% (ratio: 0->384000)
Selected audio codec: [ffaac] afm: ffmpeg (FFmpeg AAC (MPEG-2/MPEG-4 Audio))
==========================================================================
AO: [pulse] 48000Hz 2ch floatle (4 bytes per sample)
Starting playback...
Movie-Aspect is undefined - no prescaling applied.
VO: [vdpau] 1920x1088 => 1920x1088 Planar YV12
Movie-Aspect is 1.78:1 - prescaling to correct movie aspect.
VO: [vdpau] 1920x1080 => 1920x1080 Planar YV12
Dropping frame with size not matching configured size
A: 5.3 V: 5.4 A-V: -0.115 ct: -0.166 297/297 25% 7% 0.2% 10 0
Exiting... (End of file)


Mplayer will play the live stream correctly after a bit of complaining.

$ mplayer /dev/video1
MPlayer SVN-r36171-4.8.1 (C) 2000-2013 MPlayer Team
mplayer: could not connect to socket
mplayer: No such file or directory
Failed to open LIRC support. You will not be able to use your remote control.

Playing /dev/video1.
libavformat version 54.63.104 (external)
Cannot seek backward in linear streams!
Seek failed
Cannot seek backward in linear streams!
Seek failed
Cannot seek backward in linear streams!
Seek failed
Cannot seek backward in linear streams!
Seek failed
Cannot seek backward in linear streams!
Seek failed
Cannot seek backward in linear streams!
Seek failed
Cannot seek backward in linear streams!
Seek failed
Cannot seek backward in linear streams!
Seek failed
Cannot seek backward in linear streams!
Seek failed
Cannot seek backward in linear streams!
Seek failed
Cannot seek backward in linear streams!
Seek failed
TS file format detected.
Cannot seek backward in linear streams!
Seek failed
VIDEO H264(pid=4113) AUDIO AAC(pid=4352) NO SUBS (yet)! PROGRAM N. 1
Cannot seek backward in linear streams!
Seek failed
FPS seems to be: 30.000000
Load subtitles in /dev/
==========================================================================
Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family
libavcodec version 54.92.100 (external)
Selected video codec: [ffh264] vfm: ffmpeg (FFmpeg H.264)
==========================================================================
==========================================================================
Opening audio decoder: [ffmpeg] FFmpeg/libavcodec audio decoders
AUDIO: 48000 Hz, 2 ch, floatle, 0.0 kbit/0.00% (ratio: 0->384000)
Selected audio codec: [ffaac] afm: ffmpeg (FFmpeg AAC (MPEG-2/MPEG-4 Audio))
==========================================================================
AO: [pulse] 48000Hz 2ch floatle (4 bytes per sample)
Starting playback...
Movie-Aspect is undefined - no prescaling applied.
VO: [vdpau] 1920x1088 => 1920x1088 Planar YV12
[h264 @ 0x7fc1ba47d5c0]mmco: unref short failure
[h264 @ 0x7fc1ba47d5c0]mmco: unref short failure
Movie-Aspect is 1.78:1 - prescaling to correct movie aspect.
VO: [vdpau] 1920x1080 => 1920x1080 Planar YV12
Dropping frame with size not matching configured size
[h264 @ 0x7fc1ba47d5c0]mmco: unref short failure
[h264 @ 0x7fc1ba47d5c0]mmco: unref short failure
A: 17.1 V: 17.1 A-V: 0.010 ct: -0.526 430/430 24% 8% 5.4% 14 0

Exiting... (Quit)

VLC will NOT play the live stream directly, at least from the command line using the simple device.

$ vlc /dev/video1
VLC media player 2.0.8 Twoflower (revision 2.0.7-29-g12aebf9)
[0x1dca108] main libvlc: Running vlc with the default interface. Use 'cvlc' to use vlc without interface.
libdvbpsi error (PSI decoder): TS discontinuity (received 2, expected 0) for PID 0
libdvbpsi error (PSI decoder): TS discontinuity (received 2, expected 0) for PID 256

However, I can get vlc to play the live stream by setting the HDPVR device up as a PVR capture device in the gui.

vlc-> media-> capture device
set Capture Mode to PVR
set device name to /dev/video1
press Play

The command line output while I do this is:

$ vlc
VLC media player 2.0.8 Twoflower (revision 2.0.7-29-g12aebf9)
[0x917108] main libvlc: Running vlc with the default interface. Use 'cvlc' to use vlc without interface.
[0x7f9a880020d8] ts demux error: MPEG-4 descriptor not found
[0x7f9a88e6fa08] packetizer_mpeg4audio packetizer: AAC channels: 2 samplerate: 48000
Fontconfig warning: FcPattern object size does not accept value "0"
Fontconfig warning: FcPattern object size does not accept value "0"
[h264 @ 0x7f9a88d3df80] illegal short term buffer state detected

Continued in next post...
post #2 of 29
Thread Starter 
So basically I can create and view files from the HD-PVR and I can view the live output with mplayer and vlc.

What I really want to do is stream the output so that I can watch it on devices anywhere in the house, ie devices not directly connected to the HDPVRs.

*Theoretically* one can do that by selecting Stream rather than Play in the vlc GUI.

vlc-> Media -> Open Capture Device
Capture Mode = PVR
Device Name = /dev/video1

At this point my "Edit Options" are :pvr-device=/dev/video1 :pvr-radio-device=HDPVR :pvr-norm=0 :live-caching=300

I then select Stream instead of Play.

In Destination Setup, I add an HTTP destination and set the path to /stream.

As far as Transcoding, here is where things get interesting. I'm not sure I want to transcode anything. I've already demonstrated that both vlc and mplayer will play the stream directly from the HD-PVR itself. Why do I need to transcode it ?

Nevertheless, I chose Active Transcoding with a Video- H.264+MP3 profile.

At the end of all this, my "Generated stream output string" is
:sout=#transcode{vcodec=h264,vb=0,scale=0,acodec=mpga,ab=128,channels=2,samplerate=44100}:http{mux=avi,dst=:8080/stream} :sout-keep

I check that its actually running.

$ netstat -nap | grep 8080
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 18496/vlc
tcp6 0 0 :::8080 :::* LISTEN 18496/vlc

During all this the command line displays the following.
$ vlc
VLC media player 2.0.8 Twoflower (revision 2.0.7-29-g12aebf9)
[0x126f108] main libvlc: Running vlc with the default interface. Use 'cvlc' to use vlc without interface.
libdvbpsi error (PSI decoder): TS discontinuity (received 2, expected 0) for PID 0
libdvbpsi error (PSI decoder): TS discontinuity (received 2, expected 0) for PID 256
[0x7fc304002c58] ts demux error: MPEG-4 descriptor not found
[0x7fc30517ffc8] packetizer_mpeg4audio decoder: AAC channels: 2 samplerate: 48000


If I fire up another instance of VLC (via the gui) and use it to view the stream, it displays a black screen and I get this.

$ vlc
VLC media player 2.0.8 Twoflower (revision 2.0.7-29-g12aebf9)
[0x1598108] main libvlc: Running vlc with the default interface. Use 'cvlc' to use vlc without interface.
libdvbpsi error (PSI decoder): TS discontinuity (received 10, expected 0) for PID 0
libdvbpsi error (PSI decoder): TS discontinuity (received 10, expected 0) for PID 66
[0x7ff9100024b8] ts demux error: MPEG-4 descriptor not found
[0x7ff910cbdc88] packetizer_mpeg4audio packetizer: AAC channels: 2 samplerate: 48000
Fontconfig warning: FcPattern object size does not accept value "0"
Fontconfig warning: FcPattern object size does not accept value "0"
[h264 @ 0x7ff910d4e7a0] mmco: unref short failure
x 100 times...

Netstat shows this
$ netstat -nap | grep 8080
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 18496/vlc
tcp 0 0 127.0.0.1:8080 127.0.0.1:53735 TIME_WAIT -
tcp6 0 0 :::8080 :::* LISTEN 18496/vlc


When I run VLC from the command line, I get a different error.
vlc http://127.0.0.1:8080/stream
VLC media player 2.0.8 Twoflower (revision 2.0.7-29-g12aebf9)
[0x25a3108] main libvlc: Running vlc with the default interface. Use 'cvlc' to use vlc without interface.
[0x7ffc4c006558] main stream error: cannot pre fill buffer

When run mplayer from the command line, I get this

$ mplayer http://127.0.0.1:8080/stream
MPlayer SVN-r36171-4.8.1 (C) 2000-2013 MPlayer Team
mplayer: could not connect to socket
mplayer: No such file or directory
Failed to open LIRC support. You will not be able to use your remote control.

Playing http://127.0.0.1:8080/stream.
Resolving 127.0.0.1 for AF_INET6...
Connecting to server 127.0.0.1[7f00:1::]: 8080...

Failed to connect to server with AF_INET6
Connecting to server 127.0.0.1[127.0.0.1]: 8080...

Cache size set to 320 KBytes
Cache fill: 0.00% (0 bytes) nop_streaming_read error : Resource temporarily unavailable
Stream not seekable!
Cache fill: 0.00% (0 bytes) Stream not seekable!
Cache fill: 0.00% (0 bytes) Stream not seekable!
Cache fill: 0.00% (0 bytes) Stream not seekable!
Cache fill: 0.00% (0 bytes) Stream not seekable!
Cache fill: 0.00% (0 bytes)

libavformat version 54.63.104 (external)

Exiting... (End of file)

And that is as far as I have gotten.

Continued in the next post...
post #3 of 29
Thread Starter 
I forgot to mention that I am not able to connect to the HC-PVR using teh Video for Linux mode.

vlc-> Media -> Open Capture Device
Capture Mode = Video for Linux 2
Video Device name = /dev/video1
Press Play.

Result is "VLC is unable to open the MRL 'v4l2:///dev/video1"

The command line show the following.
$ vlc
VLC media player 2.0.8 Twoflower (revision 2.0.7-29-g12aebf9)
[0x1407108] main libvlc: Running vlc with the default interface. Use 'cvlc' to use vlc without interface.
[0x7f4a2c0010c8] v4l2 demux error: Could not match pixel format
[0x7f4a2c004b78] v4l2 access error: Could not match pixel format
[0x7f4a2c004b78] v4l2 access error: Could not match pixel format
[0x7f4a44000b78] main input error: open of `v4l2:///dev/video1' failed
post #4 of 29
Thread Starter 
At this point I am stuck and unsure how to proceed.

I am able to view the live output of the HDPVR device in mplayer and vlc.

It would seem as though VLC is streaming the output of the HDPVR device, but I am unable to view it.

Should I continue to struggle with trying to use VLC as my streamer ? Does anyone see why it isn't working ?

Should I try rygel or gstreamer or ffserver ?

One thing that keeps me from trying ffserver is that it seems to want to user to specify the stream format (codec, height and width) when it is invoked. My satellite receiver changes screen resolution as program content changes. SD programming, low quality commercials and the guide are output in 720i. HD is output in 1080i. It changes output formats whenever it needs to, depending on the input programming.

I know about and have played with MythTV and XBMC. I am setting my system up primarily for live TV viewing. I think what I am doing will work (much) better for live viewing than MythTV and XBMC presently do.

Any and all insight and advice to getting this working will be greatly appreciated.
post #5 of 29
What you want is basically a streaming media server. It's protocol is RTSP, that is what network media devices usually want to use, there are some others as well. The error you see in mplayer and vlc is when they open the pipe they are expecting a file or container like MKV, TS, etc. so they know what the payload is and how to control it and decode it but these programs see a stream and eventually (using various fallback tests on the stream) they find a pid in the stream and then knows what type of stream it is audio/video,etc. and then starts decoding it. for playback. To reliably deliver this stream to networks media devices you will need to use a media server that will re-encode or repackage the stream for network delivery. Here is a wiki list for linux:
https://en.wikipedia.org/wiki/List_of_streaming_media_systems
These or somewhat complex but work reasonably well and you may need a powerful server if it needs to transcode on the fly. Anyway, this will give you a starting point.
Edited by MichaelZ - 10/29/13 at 2:13pm
post #6 of 29
Thread Starter 
post #7 of 29
Thread Starter 
Quote:
Originally Posted by MichaelZ View Post

To reliably deliver this stream to networks media devices you will need to use a media server that will re-encode or repackage the stream for network delivery. Here is a wiki list for linux:
https://en.wikipedia.org/wiki/List_of_streaming_media_systems

VLC is on the list in that Wiki. "VideoLAN - GPL"

I've looked at using some of the others. I thought VLC would be a good starting point.

I'll look into what you are saying about the viewer not knowing what the stream format is.
post #8 of 29
Thread Starter 
This is really interesting.
http://www.playonscripts.com/?w=forums&p=2297

Looks like my radio entry is wrong ? I'll check it tonight when I get a chance.
post #9 of 29
I have been working on a pet project the last few years called jflicks media system and I do this all the time. VLC is the best player to use for this task as you can just fire it up to listen for UDP packets on an IP and port. Then on the HD-PVR server side I simply read from the device and write UDP packets which of course VLC reads and displays video. I have DirecTV boxes, a roku and an Apple TV connected to HD-PVRs which can be viewed on any of our TVs.

Really I thought I was the only one who wanted to do this. smile.gif

The machine that is running VLC needs to be pretty good CPU-wise as VDPAU isn't going to be fully useful in VLC until 2.2. I don't have non-nvidia hardware so I don't know how Intel/AMD perform. The point I'm trying to make is something like an Atom processor won't work well enough.

If I spent some time on it, I could probably package up a little program you could use for testing. Let me know if you would want to try something.
post #10 of 29
I had a bunch of mjpeg IP cameras who streams needed to be converted to h.264 so the data streams would be more compact as well as working with flash/html5. So, this led me to using red5 and it needed considerable hardware to encode and serve udp packets for 4 or more cameras. Fortunately we moved on to h.264 cameras so everything got somewhat simpler. I originally pre-tested with vlc but it was not stable enough to hold on to one stream much less 4 or more but it did let me figure out if it would work. BTW, this was about 2 years ago so I remember the problems I ran into but not necessarily all the fixes and work arounds. cool.gif
post #11 of 29
Thread Starter 
Quote:
Originally Posted by djb61230 View Post

I have been working on a pet project the last few years called jflicks media system and I do this all the time.
Excellent. I knew someone would be interested and/or doing this.
Quote:
VLC is the best player to use for this task as you can just fire it up to listen for UDP packets on an IP and port.
Agreed, though it would be nice if an XBMC client (front end) would read them too.
Quote:
Then on the HD-PVR server side I simply read from the device and write UDP packets which of course VLC reads and displays video.
That is exactly all that needs to be done. No transcode, no reformat, etc. Just take it from the USB, packetize it and ship it out on Ethernet.
Quote:
I have DirecTV boxes, a roku and an Apple TV connected to HD-PVRs which can be viewed on any of our TVs.
Cool ! How are you controlling these devices ? My satellite receivers have UHF remotes, but like you, I'll probably add a few more things.
Quote:
Really I thought I was the only one who wanted to do this. smile.gif
Great minds think alike !
Quote:
The machine that is running VLC needs to be pretty good CPU-wise as VDPAU isn't going to be fully useful in VLC until 2.2.
Which isn't far off. XBMC and MythTV both make use of VDPAU. I have several ASUS eeeBox self contained PCs with Atoms and Nvidia Ions with VDPAUs in them.
Quote:
I don't have non-nvidia hardware so I don't know how Intel/AMD perform. The point I'm trying to make is something like an Atom processor won't work well enough.
Agreed. I have streamed 1080P MKV to my EeeBoxes. They handle the stream with about 30% CPU usage. XBMC only started using VDPAU a little while ago and there was a bug in the nVidia driver that caused problems too.
Quote:
If I spent some time on it, I could probably package up a little program you could use for testing. Let me know if you would want to try something.
I would love to. What did you write it in ? C, C++ or Python ? I'll share whatever I contribute, of course.
post #12 of 29
I use CVLC with my Hauppauge 1600 to stream live OTA channels, works great. The command I use is the following, maybe you could modify it to get it working with your feed.
Quote:
cvlc dvb:// :dvb-frequency=575000000 :dvb-bandwidth=0 :program=3 :dvb-modulation=8 --novideo --sout '#transcode{vcodec=h264,vb=600,scale=0.25,acodec=mp3,ab=96,channels=2,samplerate=44100}:http{mux=ffmpeg{mux=flv},dst=:8085/}'

This actually streams live TV to my cell phone over the Internet which is why I'm using bit rate of 600Kbps and scale the video down by 1/4. I use MX player on my Android phone to view the stream. VLC on my desktop devices to view it there.
Edited by bac522 - 10/30/13 at 7:47am
post #13 of 29
Thread Starter 
While we are discussing this, I might as well tell you that what I would really like to do is stream the satellite receivers as a DLNA stream. This would make training the people in my house a lot easier, as well as it would work directly on our Samsung TVs without the need for a HTPC at each one. (I know there are advantages to having a HTPC at each TV though...)

As far as I know none of the DLNA servers will operate with a non static files as an input. Ie, none will work with a character device like /dev/video1.

However, this guy was able to stream a live desktop over DLNA by using a script to handle providing the DLNA server what looked like a file.
http://realmike.org/blog/2011/02/09/live-desktop-streaming-via-dlna-on-gnulinux/

I think I am going to modify miniDLNA so that it could handle a character device file as an input, as /dev/video* is.

At some point it would be nice to include ffmpeg in the process to transcode things where needed. Or maybe its been done already ? http://phoronix.com/forums/showthread.php?74223-MiniDLNA-transcode-DLNA-server-announcement

Samsung DLNA video formats.
http://forums.cnet.com/7723-13973_102-322838/dlna-formats-supported/

Its going to be a bit of work to code the character device functionality into minidlna, but it seems like such a simple solution compared to setting up live TV in XBMC or MythTV. I've done the latter, it was no fun and XBMC live TV doesn't appear to be ready for prime time yet. In the mean time, a live stream of my satellite receivers would work great.

The ultimate solution might be to have 1 receiver as a dedicated PVR source in XBMC and the other receiver for live viewing via a DLNA stream.

Maybe I should add the character device functionality to the DLNA server in XBMC and then a receiver could be used for both live TV (via the DLNA stream) and for PVR duty ????

Any thoughts on all this ?
Edited by elmerfudII - 10/30/13 at 9:52am
post #14 of 29
Quote:
Originally Posted by bac522 View Post

I use CVLC with my Hauppauge 1600 to stream live OTA channels, works great. The command I use is the following, maybe you could modify it to get it working with your feed.
This actually streams live TV to my cell phone over the Internet which is why I'm using bit rate of 600Kbps and scale the video down by 1/4. I use MX player on my Android phone to view the stream. VLC on my desktop devices to view it there.

Not sure if this helps, as I've haven't read thru everything but......

I've used a similar command line to stream TV over internet or locally to a tablet. Source in my case is HDHR tuner with the tuner already set to a channel. I did a lot of work to find the optimal transcode setup. I found that adjusting the scale & fps is the best way to find a workable bandwidth; The fps must be exactly 1/2 or 1/4 the actual fps or it will cause transcoding hell, or just don't specify fps at all. The quality of the output stream is has been quite good...

vlc -vvv "udp://@:5000" --sout "#transcode{vcodec=h264,scale=0.3,fps=29.97002975,vb=0,acodec=mp3,ab=128,channels=2,samplerate=22050}:standard{access=http,mux=ts,ttl=45,dst=:8979/}"
post #15 of 29
Quote:
Originally Posted by elmerfudII View Post


Cool ! How are you controlling these devices ? My satellite receivers have UHF remotes, but like you, I'll probably add a few more things.

I would love to. What did you write it in ? C, C++ or Python ? I'll share whatever I contribute, of course.

After seeing some of the posts above, you could probably use VLC on both ends. I wrote jflicks in Java, well because I've been doing Java all day like for 15 years so I can get things done pretty quick. Plus I like it. The code is not complicated but a bit much to post here.

The direcTV boxes, if they are fairly modern, come with ethernet ports. If you plug them into your network, you can access a web service on them to be able to do things like change the channel. Thats what I do for jflicks. I mean to me the direcTV boxes are just video sources and all I need to do is set the channel. I don't try to control the menus and such. And it's been a while since I did the channel changing code and I don't remember exactly what they do support via their web service. I think they have a document on the web somewhere but it would take some googling to find it.

You could poke around the source on github if you want.

https://github.com/djb61230/jflicks

For the streaming code look at a class called StreamJob in src/org/jflicks/tv/recorder along with it's parent class RecorderJob.

For the channel changing code look at DirectvWeb.java in src/org/jflicks/stb/directvweb.

For jflicks to change the channel I have an executable jar file that I exec at runtime. And for a quick test I could make an executable jar to do the streaming. I'll go do that and attach them to a follow-up post. But if you wanted to test them you need Java 7 installed - I use openjdk.


Edit - Ok got things tested and ready:

To change the channel on a directive box:

java -jar directvweb.jar -host xxx.xxx.xxx.xxx -channel NUMBER

The host of course is the IP address of the direcTV box. The channel is something like 202 or whatever.

To start a stream:

java -jar teststreamjob.jar -i /dev/videoN -h xxx.xxx.xxx.xxx -p NNNN -s N

So supply the /dev device connected to the directv box. The host/IP and Port where you are running VLC in UDP mode. The -s argument is a number of seconds to stream. The test program will exit after N seconds. I tested this with a linux server with an HD-PVR and sending video to my Mac and VLC.

One thing I'm glossing over - the HD-PDR has settings on bit rate, audio device etc. In jflicks I use the v4l2-ctl command line program that can set these things for video4linux type hardware. If you do this test it will stream at the current settings - hopefully they are valid so it works. smile.gif

Please let me know if you have any questions. I don't want to hijack your thread (more than I have) so you can PM me if you prefer.




jflicks-test.zip 150k .zip file
Edited by djb61230 - 10/30/13 at 4:43pm
post #16 of 29
Thread Starter 
Quote:
Originally Posted by djb61230 View Post


You could poke around the source on github if you want.

https://github.com/djb61230/jflicks

Thanks for sharing that ! It looks like a really neat application.

After giving it some thought and looking at the minidlna code, I have decided that the best way for me to proceed is to add character device file support to minidlna. Should I like how that turns out, I'll probably do something similar for XBMC as well.

If TVs supported receiving a UDP stream, I'd do what you did. My TVs only support DLNA.

Though I have only written a couple tiny apps in it, I like Java. I think its a great solution for apps that need to run on multiple platforms, though I suspect that in a few years just about everything is going to support Qt or some Qt/KDE hybrid.

BTW, what is the latency on your system when using the remote control ? Ie, how long from pressing the button to change the channel until the channel content appears on your device ?

Thanks again.

I'll keep this thread updated with my progress.
Quote:
I don't want to hijack your thread (more than I have) so you can PM me if you prefer.
On the contrary, hijack all you want. Its very informative to see what others have done.
Edited by elmerfudII - 10/31/13 at 1:36pm
post #17 of 29
Thread Starter 
I recorded a file from my PV-HDR with cat /dev/video1 > test.ts.

I copied the file to a USB flash drive.

I opened the USB drive on my Samsung LN52A750. When I play the file, the screen flashes and then it ends.

I'm not sure if it will play differently as a streamed DLNA file or not. I might need to transcode the HD-PVR stream so it will play properly on my TV. The other option would be to connect the TV to a Raspberry Pi running XBMC and play it with that.
post #18 of 29
Thread Starter 
Quote:
Originally Posted by djb61230 View Post


To start a stream:

java -jar teststreamjob.jar -i /dev/videoN -h xxx.xxx.xxx.xxx -p NNNN -s N

So supply the /dev device connected to the directv box. The host/IP and Port where you are running VLC in UDP mode. The -s argument is a number of seconds to stream. The test program will exit after N seconds. I tested this with a linux server with an HD-PVR and sending video to my Mac and VLC.

This app works very well. Thank you for creating it.

How are you viewing your stream in vlc ? If you do it from the command line, what parameters and options are you using ?

I am viewing my stream with mplayer. Not because I want to, but because it works, mostly. Here is what I get.

$ mplayer udp://127.0.0.1:8080/
MPlayer SVN-r36171-4.8.1 (C) 2000-2013 MPlayer Team
mplayer: could not connect to socket
mplayer: No such file or directory
Failed to open LIRC support. You will not be able to use your remote control.

Playing udp://127.0.0.1:8080/.
STREAM_UDP, URL: udp://127.0.0.1:8080/
Stream not seekable!
libavformat version 54.63.104 (external)
Stream not seekable!
Stream not seekable!
Stream not seekable!
Stream not seekable!
Stream not seekable!
Stream not seekable!
Stream not seekable!
Stream not seekable!
Stream not seekable!
Stream not seekable!
Stream not seekable!
Stream not seekable!
Stream not seekable!
Stream not seekable!
Stream not seekable!
Stream not seekable!
Stream not seekable!
Stream not seekable!
Stream not seekable!
Stream not seekable!
Stream not seekable!
TS file format detected.
Stream not seekable!
VIDEO H264(pid=4113) AUDIO AAC(pid=4352) NO SUBS (yet)! PROGRAM N. 1
Stream not seekable!
FPS seems to be: 30.000000
Failed to open VDPAU backend libvdpau_nvidia.so: cannot open shared object file: No such file or directory
[vdpau] Error when calling vdp_device_create_x11: 1
==========================================================================
Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family
libavcodec version 54.92.100 (external)
Selected video codec: [ffh264] vfm: ffmpeg (FFmpeg H.264)
==========================================================================
==========================================================================
Opening audio decoder: [ffmpeg] FFmpeg/libavcodec audio decoders
AUDIO: 48000 Hz, 2 ch, floatle, 0.0 kbit/0.00% (ratio: 0->384000)
Selected audio codec: [ffaac] afm: ffmpeg (FFmpeg AAC (MPEG-2/MPEG-4 Audio))
==========================================================================
AO: [pulse] 48000Hz 2ch floatle (4 bytes per sample)
Starting playback...
Movie-Aspect is undefined - no prescaling applied.
VO: [xv] 1920x1088 => 1920x1088 Planar YV12
[h264 @ 0x7f6733d6d5c0]mmco: unref short failure
[h264 @ 0x7f6733d6d5c0]mmco: unref short failure
Movie-Aspect is 1.78:1 - prescaling to correct movie aspect.
VO: [xv] 1920x1080 => 1920x1080 Planar YV12
Dropping frame with size not matching configured size
[h264 @ 0x7f6733d6d5c0]mmco: unref short failure
[h264 @ 0x7f6733d6d5c0]mmco: unref short failure
A:1100.3 V:1100.6 A-V: -0.312 ct: -0.948 591/591 15% 1% 0.1% 2 0
[h264 @ 0x7f6733d6d5c0]left block unavailable for requested intra mode at 0 15
[h264 @ 0x7f6733d6d5c0]error while decoding MB 0 15, bytestream (4406)
A:1100.4 V:1101.0 A-V: -0.638 ct: -0.954 596/596 16% 1% 0.1% 2 0
[h264 @ 0x7f6733d6d5c0]error while decoding MB 90 33, bytestream (-12)
A:1100.7 V:1101.0 A-V: -0.367 ct: -0.958 598/598 16% 1% 0.1% 2 0
[h264 @ 0x7f6733d6d5c0]Cannot combine reference and non-reference fields in the same frame
[h264 @ 0x7f6733d6d5c0]If you want to help, upload a sample of this file to ftp://upload.ffmpeg.org/MPlayer/incoming/ and contact the ffmpeg-devel mailing list.
[h264 @ 0x7f6733d6d5c0]decode_slice_header error
A:1102.8 V:1103.0 A-V: -0.189 ct: -1.144 714/714 17% 1% 0.6% 2 0
[h264 @ 0x7f6733d6d5c0]Cannot combine reference and non-reference fields in the same frame
[h264 @ 0x7f6733d6d5c0]If you want to help, upload a sample of this file to ftp://upload.ffmpeg.org/MPlayer/incoming/ and contact the ffmpeg-devel mailing list.

I invoked your app with

$ java -jar teststreamjob.jar -i /dev/video0 -p 8080 -s 3600
input
host
port <8080>
seconds <3600>


I haven't looked at the source... I don't understand the host parameter. Is it the address of the machine teststream is running on or the address of the client that wants to (is allowed to) access it ? Could it be a block of addresses ?

Thanks again for taking the time to help me like this. Greatly appreciated.
post #19 of 29
Thread Starter 
Got VLC to work as a viewer.
$ vlc udp://@127.0.0.1:8080
VLC media player 2.0.8 Twoflower (revision 2.0.7-29-g12aebf9)
[0xcf2108] main libvlc: Running vlc with the default interface. Use 'cvlc' to use vlc without interface.
libdvbpsi error (PSI decoder): TS discontinuity (received 9, expected 0) for PID 0
libdvbpsi error (PSI decoder): TS discontinuity (received 9, expected 0) for PID 256
[0x7f3cbc00d018] ts demux error: MPEG-4 descriptor not found
[0x7f3cbc26be38] packetizer_mpeg4audio packetizer: AAC channels: 2 samplerate: 48000
Fontconfig warning: FcPattern object size does not accept value "0"
Fontconfig warning: FcPattern object size does not accept value "0"
[h264 @ 0x7f3cbc13f520] Cannot combine reference and non-reference fields in the same frame
[h264 @ 0x7f3cbc13f520] If you want to help, upload a sample of this file to ftp://upload.ffmpeg.org/MPlayer/incoming/ and contact the ffmpeg-devel mailing list.
[h264 @ 0x7f3cbc13f520] decode_slice_header error
post #20 of 29
Thread Starter 
I'm now having a problem accessing the stream across the network.

VLC on the local machine has no problem accessing the stream. Neither VLC nor mplayer can access it over the network. All firewalls have been disabled.

netstat -nap |grep "port number" is not returning anything. It doesn't look like the port is open.

ssh works fine between the client and the server.
post #21 of 29
Thread Starter 
Is there a way to stop the process nicely ? ctrl C stops it, but it messes something up as the next time it runs I get (over and over)

We are probably blocking.../dev/video0
Times we failed on a block: 1 /dev/video0
Attempting to close! /dev/video0
We have been interupted!
Close seemed to work. /dev/video0
We are trying to reset! /dev/video0
Getting new fileChannel.../dev/video0
Got new fileChannel./dev/video0

I understand its a test program, it was free and I have the code in front of me... LOL.

If I power cycle the PVR and restart the program this problem doesn't happen. FYI, I'm running F19 and I've upgraded the PVR firmware to the latest version. (dmesg says "firmware version 0x1e dated Mar 7 2012 08:25:15")
post #22 of 29
Hey - so it looks like you basically got it to work with VLC which is very cool. Did you get it to work over the network? It should work as long as you use the right IP and port. Let's say the HD-PVR machine is IP 192.168.1.5 and the client machine is 192.168.1.10

java -jar teststreamjob.jar -i /dev/video0 -h 192.168.1.10 -p 8080 -s 60

Then vlc on the other machine:

vlc udp://@192.168.1.10:8080

I think thats what you want. To test that the port is open you could try to telnet to it from the linux box:

telnet 192.168.1.10 8080

I don't know exactly the output but if it was blocked or is OK, the output message from telnet should let you know what is up.

So yeah in the real jflicks server-side it has a Timer thread that stops things when it's supposed to. Thats either at the end of a recording or when the user stops LiveTV. Those messages you see is also the code having a "babysitter" thread because over the years with different kernels/drivers the HD-PVR has gone to la-la-land and the babysitter thread is trying to interrupt the blocking read, then trying again. As you saw it doesn't always work. ;^)

What would be a better way to make the little program easier to control for you? I assume you are at this point just wanting to avoid the ctrl-c. I mean it should not get into the weird state if the current program times out (the -s 60) argument. I could also have it wait for a key on stdin in addition to using the -s argument. That way you could end it early without doing the ctrl-c and hosing it. What do you think? I can add that after work tonight.

You asked this earlier I think - yes there is a latency. I find it's about a second. This functionality I use mostly for my roku and apple tv. The second delay isn't too bad really, we are all used to it. The roku I had to write special code to send messages from my client to the server then to a service that runs on the roku. The apple tv is easier because we just use our iPhone/iPad and the apple Remote app and it controls it over wifi.
Edited by djb61230 - 11/4/13 at 6:23am
post #23 of 29
Thread Starter 
Thanks for the reply. I'm just getting time to work on this again today.

I still can't get a connection on a client.

Telnet fails. Give me a no route to host error.

Here is what nmap gives me. My server's IP is 192.168.1.110.

# nmap -v -O 192.168.1.110

Starting Nmap 6.40 ( http://nmap.org ) at 2013-11-16 16:03 MST
Initiating ARP Ping Scan at 16:03
Scanning 192.168.1.110 [1 port]
Completed ARP Ping Scan at 16:03, 0.02s elapsed (1 total hosts)
Initiating Parallel DNS resolution of 1 host. at 16:03
Completed Parallel DNS resolution of 1 host. at 16:03, 0.01s elapsed
Initiating SYN Stealth Scan at 16:03
Scanning 192.168.1.110 [1000 ports]
Discovered open port 139/tcp on 192.168.1.110
Discovered open port 445/tcp on 192.168.1.110
Discovered open port 22/tcp on 192.168.1.110
Completed SYN Stealth Scan at 16:04, 5.06s elapsed (1000 total ports)
Initiating OS detection (try #1) against 192.168.1.110
Retrying OS detection (try #2) against 192.168.1.110
Nmap scan report for 192.168.1.110
Host is up (0.0016s latency).
Not shown: 997 filtered ports
PORT STATE SERVICE
22/tcp open ssh
139/tcp open netbios-ssn
445/tcp open microsoft-ds
MAC Address: F4:6D:04:7A:E3:67 (Asustek Computer)
Warning: OSScan results may be unreliable because we could not find at least 1 open and 1 closed port
Aggressive OS guesses: Linux 2.6.32 - 3.6 (93%), Linux 2.6.32 - 3.9 (93%), Linux 3.0 - 3.9 (93%), Linux 2.6.32 (90%), Linux 2.6.22 - 2.6.36 (90%), Linux 2.6.39 (90%), Crestron XPanel control system (89%), Netgear DG834G WAP or Western Digital WD TV media player (89%), Linux 3.3 (89%), Linux 2.6.32 - 2.6.35 (88%)
No exact OS matches for host (test conditions non-ideal).
Uptime guess: 0.001 days (since Sat Nov 16 16:02:02 2013)
Network Distance: 1 hop
TCP Sequence Prediction: Difficulty=262 (Good luck!)
IP ID Sequence Generation: All zeros

Read data files from: /usr/bin/../share/nmap
OS detection performed. Please report any incorrect results at http://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 9.48 seconds
Raw packets sent: 2057 (94.104KB) | Rcvd: 4310 (1.037MB)

It pings just fine. I'm ssh'd into it all the time. So I know the network connection is fine and the server is up and running.

I'm running the test app as root. I've opened the firewall port 8080 for UDP on the server. Do I need to do anything else ? I can connect fine from local host, so it seems like a permission issue ????

There are no error messages on the test command line.

Any ideas ?
post #24 of 29
Thread Starter 
So... I've spent hours trying to debug the test app you provided as well as miniDLNA as well as rygel. I can get none of them to work.

With your test app, I can't telnet the port, even though I have 8080 UDP and TCP open. I have similar problems with the other apps, and they all work locally on the server. And minidlna worked fine (with selinux disabled) before I upgraded the server to F19.

I suspect the problem is that Fedora 19 uses Network Manager (by default) to control access to the network devices. I suspect this because its the only thing between the application and the client other than the firewall. And the rygel FAQ has a little blurb about it.
Quote:
Rygel seems unwilling to bind to any interface other than 127.0.0.1, despite -n or interfaces=.

A symptom for this problem is that you can not see the Rygel server on your network. You can confirm that this is an issue by running Rygel with debug output, and look for lines like this:

(rygel:4791): Rygel-DEBUG: rygel-main.vala:137: New network 127.0.0.0 (lo) context available. IP: 127.0.0.1

If you only get the above line, and nothing about eth0 or wlan0 (in addition to lo), or any other interface, this indicates that you are using GUPnP which is compiled with the NetworkManager context manager and NetworkManager is running, but you're not using it for global device configuration but relying on e.g. /etc/network/interfaces. Possible solutions

Switch to NetworkManager.

Recompile GUPnP with the "unix" context manager. This will drop the automatic detection of interfaces going up and down as well as address changes.

For Rygel >= 0.11.1: Recompile GUPnP with the "linux" context manager.

Source: https://wiki.gnome.org/Rygel/FAQ

Furthermore, Fedora changed their naming protocol for network devices. Before the names were randomly assigned according to when they were recognized. Eth0, eth1, etc. Now they are assigned names by their hardware position. p6p1, for example.

When I look in hostname.java, getHostname and other routines, rely on getting info from getNetworkInterfaces(). I'm wondering what that is returning and if there should be a warning if nothing is returned other than the lo. I obviously haven't tried running your code in a debugger yet. Any comments on all this ?

On another point... OMG you have done a lot of work on this app ! Have you advertised the project ? Seems as though its the basis of a really good system ?
post #25 of 29
Thread Starter 
from $ grep -r "network" of source:

jflicks/util/Hostname.java: // let's look for /etc/network/interfaces and try to get a static
jflicks/util/Hostname.java: String[] lines = Util.readTextFile(new File("/etc/network/interfaces"));

On my server:

# ls /etc/net*
/etc/netconfig /etc/networks

# ls /etc/NetworkManager
dispatcher.d dnsmasq.d NetworkManager.conf system-connections VPN

I may be way off in left field here.
post #26 of 29
Thread Starter 
FYI, there is a newer version of minidlna out, version 1.1.1. I was testing with 1.1.0 installed via yum.

The README on it says
Quote:
1.1.1 - Released 01-Nov-2013
- Add network interface monitoring support on Linux.
- Don't require a configured network interface to start up.
- Fix some minor spec compliance issues.

I built it on my laptop and it works.
post #27 of 29
Thread Starter 
My project is taking a left turn.

On the weekend I found out that the UHF remote controls on my satellite receivers (Motorola) have very poor range in my house. It doesn't pay to stream their output all over the house if I can't control the receivers in the first place. I could implement a network of IR receivers at each TV location and then use that to control the receivers, but that seems like a lot of work for limited benefit.

I think I am going to wait for version 13 of XBMC and implement a live TV system with it.

This was still a very interesting and educational exercise.
post #28 of 29
Yes, and you can remote control XBMC from your smartphone over WIFI.

The mythtv pvr backend works great as well as the newer WMC one still in beta. I'm considering the latter with windows in a vm for cablecard viewing (hdhomerun prime).
post #29 of 29

I wrote a script in Ubuntu (bash) for an organization that does exactly what you are looking for. Note: It took me a couple years to figure out a workable solution, and I'm happy to now share with others.

 

I ran into a few problems, which is why the script is formatted the way it is:

1) Hauppauge HD PVR (the first, not "2"), does not generate a timecode. Needed something to generate this code for me.

2) VLC couldn't read the raw stream from /dev/video?

Depending on streaming needs:

3) Needed ability to stream to multicast, which I later depreciated in my organization. Also needed to stream to a broadcast server.

4) Needed ability for hauppauge stream server to host stream for end-users.

 

Copy and paste the following into a blank file on Ubuntu, then mark it as executable. Use "screen" if using a headless server.

Note: Feel free to copy, distribute this script, in part or entirety however you want. All I ask is that somewhere, credit is given to "Fishscene" and/or "Core"

---------------

#!/bin/bash
## Script by Fishscene/Core
## Depends (software): multicat, vlc
## Depends (hardware): "hauppauge hd pvr" (NOT the 2nd version)
clear

## =============================================
## Begin User-editable section
## =============================================
## Name of Listening Options
opt0="Kill all streaming"
opt1="Stream server"
opt2="Broadcast to network (Not recommended)"


## Port that stream will be hosted on.
EXTERNALPORT=3000

## Multicast or UDP Target to stream to
M_EXTERNALIP=239.254.0.20

## Channel name to receive the stream on. Example: http://127.0.0.1:2002/(channel)
## Name this whatever you want.
CHANNEL=test


## =============================================
## End of User-editable section
## Begin variable setup
## =============================================


## IP address and port to use to stream multicat to VLC
INTERNALIP=127.0.0.1
INTERNALPORT=2000

## Grabs the hostname of the server
SERVERNAME=`eval hostname`

## Grabs current IP address of host
EXTERNALIP=`eval ifconfig | awk '{print $2}' | grep -E -o '(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)' | head -n 1`

## Notification
startnotify=$(date +'%Y-%m-%d %H:%M:%S %Z')" - $USER initiated $humanr: $green $bold[Started]$endcol \nPress $bold[CTRL]+[C]$endcol to stop."


## Color codes, Changes colors of the terminal text.
red=$(tput setaf 1)
green=$(tput setaf 2)
yellow=$(tput setaf 3)
blue=$(tput setaf 4)
purple=$(tput setaf 5)
teal=$(tput setaf 6)
white=$(tput setaf 7)
bold=$(tput bold)
endcol=$(tput sgr0)

 

## =============================================
## End of Variable setup
## Begin Script functions
## =============================================

 

## Pause function ("Bash Cookbook - O'Reilly")
f_pause()
{
    read -p 'Press any key to continue...'
}


## Kills streaming services, Multicat and VLC.
#Can only have one multicat and one vlc service at a time. Otherwise, confusion.
f_killstream()
{
sudo killall -9 multicat
sudo killall -9 vlc
sleep 1
}


## Determins where hauppauge hd pvr is located
#This assumes you only have one hauppauge plugged in.
if [ -a "/dev/video0" ]; then {
        STREAMFILE=/dev/video0
} fi

if [ -a "/dev/video1" ]; then {
        STREAMFILE=/dev/video1
} fi

 

## =============================================
## End of Script functions
## Begin root menu
## =============================================

 

## Echo's user-editable list of stream actions to terminal
# Start here
cat << CHOICES
$teal
0. $opt0
1. $opt1
2. $opt2
$endcol
CHOICES
# End here

echo -n $yellow"Enter a number and press [ENTER]: "$endcol
read choice
echo $choice

## Creates a new variable based off of what the user selects.
eval humanr=\$opt${choice} #http://tldp.org/LDP/abs/html/ivr.html


## =============================================
## End of root menu
## Begin execution
## =============================================


for (( ; ; ))    # Creates infinite loop (http://www.cyberciti.biz/faq/bash-for-loop/)
do

startnotify=$(date +'%Y-%m-%d %H:%M:%S %Z')" - $USER initiated $humanr: $green $bold[Started]$endcol"

    if [ "$choice" == "0" ]; then
        humanr="Kill streaming services"
        echo -e $startnotify
        f_killstream
        echo "$green$bold[Success]$endcol"

    elif [ "$choice" == "1" ]; then
        humanr="Streaming server"
        echo -e $startnotify
        f_killstream
        sudo nohup multicat $STREAMFILE $INTERNALIP:$INTERNALPORT 2> /dev/null&
        sleep 2
        eval vlcoutput=#http{mux=$mux,dst=:$EXTERNALPORT/$CHANNEL}
        cvlc rtp://$INTERNALIP:$INTERNALPORT --sout '#http{mux=$mux,dst=:'$EXTERNALPORT'/'$CHANNEL'}' --sout-all --ttl=3 --sout-keep 2> /dev/null&
        echo "$green$bold[Success]$endcol"
        echo ""
        echo "Watch at http://"$EXTERNALIP":"$EXTERNALPORT"/"$CHANNEL "or http://"$SERVERNAME":"$EXTERNALPORT"/"$CHANNEL

    elif [ "$choice" == "2" ]; then
        humanr="Streaming server"
        echo -e $startnotify
        f_killstream

        sudo nohup multicat $STREAMFILE $M_EXTERNALIP:$EXTERNALPORT 2> /dev/null&
        sleep 2
        echo "$green$bold[Success]$endcol"
        echo ""
        cvlc rtp://$INTERNALIP:$INTERNALPORT --sout '#http{mux=$mux,dst=:$EXTERNALPORT/$CHANNEL}' --sout-all --ttl=3 --sout-keep 2> /dev/null&
        echo "Watch at http://"$M_EXTERNALIP":"$EXTERNALPORT"/"$CHANNEL
        f_pause

    fi

echo ""
echo 'The script will now close,'
f_pause
echo ""
exit 1
done

New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: HTPC - Linux Chat
AVS › AVS Forum › Video Components › Home Theater Computers › HTPC - Linux Chat › Live streaming from an HD-PVR ? (vlc streaming, ffserver, rygen ???)