TiVo Community Forum banner
441 - 460 of 481 Posts

·
Well-Known Mumbler
Joined
·
12,532 Posts
Discussion Starter · #442 ·
I have hmevlc running however none of the URL's in the config.ini file show up. The RSS feeds and Video directories do. Any thoughts?
Are you saying the streams won't play, or they don't even appear in the menu? If it's the latter, I'd assume that HME/VLC can't find a working copy of VLC.

If it's the former... yeah, most of the example streams are dead now. :(
 

·
Registered
Joined
·
74 Posts
Appears to be the later as when I remove the needs VLC True line from config they now appear on the menu (but obviously stream doesnt play witout VLC now). I have VLC installed and it works when I use it from the command line but HME/VLC seems to have problems locating VLC. Any thoughts?

Running on Linux
 

·
Registered
Joined
·
74 Posts
Thanks I was able to get HMEVLC to see VLC with your advise above. When I run a URL requiring VLC (NB I can play the URL in my web browser), HMEVLC throws the following errors:

Code:
./start.py
HME Server for Python 0.20
Sun Dec  9 15:33:47 2012 Server Starts
Registering: hmevlc
Registering: test
192.168.0.4:56322 - - [09/Dec/2012 15:34:07] "GET /hmevlc/ HTTP/1.1" 200 -
192.168.0.4:56322 - - [09/Dec/2012 15:34:07] Starting HME: hmevlc
VLC media player 0.9.9a Grishenko
[00000001] main libvlc debug: VLC media player - version 0.9.9a Grishenko - (c) 1996-2009 the VideoLAN team
[00000001] main libvlc debug: libvlc was configured with ./configure  '--build=i386-pc-linux-gnu' '--host=i686-linux-gnu' '--target=i686-linux-gnu' '--prefix=/opt' '--enable-v4l' '--disable-v4l2' '--enable-bonjour' '--enable-x264' '--enable-dvbpsi' '--enable-a52' '--enable-dvdnav' '--with-dvdnav-config-path=/home/slug/optware/syno-i686/staging/opt/bin' '--enable-faad' '--enable-flac' '--disable-gnutls' '--enable-mpc' '--enable-ncurses' '--enable-ogg' '--enable-png' '--disable-remoteosd' '--enable-shout' '--enable-speex' '--enable-vorbis' '--disable-alsa' '--disable-dca' '--disable-glx' '--disable-gnomevfs' '--disable-libcdio' '--disable-libcddb' '--disable-screen' '--disable-sdl' '--disable-wxwidgets' '--disable-skins2' '--disable-x11' '--disable-nls' '--disable-static' 'build_alias=i386-pc-linux-gnu' 'host_alias=i686-linux-gnu' 'target_alias=i686-linux-gnu' 'CC=/home/slug/optware/syno-i686/toolchain/gcc-4.2.1-glibc-2.3.6/i686-linux-gnu/bin/i686-linux-gnu-gcc' 'LDFLAGS= -L/home/slug/optware/syno-i686/staging/opt/lib -Wl,-rpath,/opt/lib -Wl,-rpath-link,/home/slug/optware/syno-i686/staging/opt/lib ' 'CPPFLAGS=-O2   -O2 -pipe -I/home/slug/optware/syno-i686/staging/opt/include -I/home/slug/optware/syno-i686/staging/opt/include/ncurses' 'CPP=/home/slug/optware/syno-i686/toolchain/gcc-4.2.1-glibc-2.3.6/i686-linux-gnu/bin/i686-linux-gnu-gcc -E' 'CXX=/home/slug/optware/syno-i686/toolchain/gcc-4.2.1-glibc-2.3.6/i686-linux-gnu/bin/i686-linux-gnu-g++' 'PKG_CONFIG_PATH=/home/slug/optware/syno-i686/staging/opt/lib/pkgconfig'
[00000001] main libvlc debug: translation test: code is "C"
[00000310] dummy interface: using the dummy interface module...
[00000316] main access out error: no sout access module matched "http"
[00000315] stream_out_standard stream out error: no suitable sout access module for `http/ps://:9028'
[00000313] stream_out_transcode stream out error: cannot create chain
[00000312] main stream output error: stream chain failed for `transcode{vcodec=mp2v,vb=2048,acodec=a52,ab=384,audio-sync,samplerate=48000,fps=30}:std{access=http,dst=:9028,mux=ps}'
[00000311] main input error: cannot start stream output instance, aborting
Any ideas?
 

·
Registered
Joined
·
74 Posts
I figured out my error above and vlc is now transcoding my stream and things are working fine..... when I start HMEVLC through a terminal window. I then wrote a start up script that would start HMEVLC on my NAS at boot time so that I don't need a terminal window open on my PC. HMEVLC starts fine under this method except anything requiring vlc no longer works again. Below is my start up script. Any thoughts appreciated.

Code:
#!/bin/sh
#
# Startup script for HMEVLC.. put in /usr/local/etc/rc.d

HMEFORPYTHON=/usr/local/hmeforpython/start.py

case "$1" in

start)
	if [ -x "$HMEFORPYTHON" ] ; then
		sleep 60
		echo "Starting HME for Python..."
		cd usr/local/hmeforpython
		/opt/bin/python /usr/local/hmeforpython/start.py > /dev/null 2>&1 &
	fi
	;;

stop)
	echo "Stopping HME for Python......."
	kill -9 `ps |grep hmeforpython/start.py | awk -F" " '{print $1}'` > /dev/null 2>&1
	;;

*)
	echo "usage: $0 { start | stop }" >&2
	exit 1
	;;

esac
 

·
Registered
Joined
·
6,933 Posts
I figured out my error above and vlc is now transcoding my stream and things are working fine..... when I start HMEVLC through a terminal window. I then wrote a start up script that would start HMEVLC on my NAS at boot time so that I don't need a terminal window open on my PC. HMEVLC starts fine under this method except anything requiring vlc no longer works again. Below is my start up script. Any thoughts appreciated.

Code:
#!/bin/sh
#
# Startup script for HMEVLC.. put in /usr/local/etc/rc.d

HMEFORPYTHON=/usr/local/hmeforpython/start.py

case "$1" in

start)
	if [ -x "$HMEFORPYTHON" ] ; then
		sleep 60
		echo "Starting HME for Python..."
		cd usr/local/hmeforpython
		/opt/bin/python /usr/local/hmeforpython/start.py > /dev/null 2>&1 &
	fi
	;;

stop)
	echo "Stopping HME for Python......."
	kill -9 `ps |grep hmeforpython/start.py | awk -F" " '{print $1}'` > /dev/null 2>&1
	;;

*)
	echo "usage: $0 { start | stop }" >&2
	exit 1
	;;

esac
I suggest not re-directing to /dev/null. Instead, I would not employ a redirection in the init script, at all. What I do is call a startup script from the init script. That way the init script should never hang the system. Then in the startup script, I redirect the output to a log file, rather than /dev/null using nohup. I'm not familiar enough with Red Hat derivatives to know for sure, but in the Debian System V init every init script is supposed to terminate. Even if it is not the case on your system, it is a good idea to make sure the init scripts do terminate. For more specific info, may I suggest you see this thread. You'll see some of the init and startup scripts I created there.

The other issue could be vlc. I know it does not like running as root, which probably is the case with your script. Redirecting to a log file will help determine if this is the case. You might need to implement a sudo in the calling script.
 

·
Registered
Joined
·
74 Posts
Yes appears to have the issue of vlc running as root. I am not familiar with sudo any examples of how this would look in the script?

I suggest not re-directing to /dev/null. Instead, I would not employ a redirection in the init script, at all. What I do is call a startup script from the init script. That way the init script should never hang the system. Then in the startup script, I redirect the output to a log file, rather than /dev/null using nohup. I'm not familiar enough with Red Hat derivatives to know for sure, but in the Debian System V init every init script is supposed to terminate. Even if it is not the case on your system, it is a good idea to make sure the init scripts do terminate. For more specific info, may I suggest you see this thread. You'll see some of the init and startup scripts I created there.

The other issue could be vlc. I know it does not like running as root, which probably is the case with your script. Redirecting to a log file will help determine if this is the case. Yoou might need to implement a sudo in the calling script.
 

·
Registered
Joined
·
6,933 Posts
sudo -u <user> <command>

You could run the startup script with sudo from the init script, but if it were me, I think I would do something like

nohup sudo -u <user> /opt/bin/python /usr/local/hmeforpython/start.py

from within the startup script.
 

·
Registered
Joined
·
6,933 Posts
Well, I can't speak for every version of sudo or login, but a non-interactive shell should not time out. You might try `su -c <command> <user>`, instead of sudo. I can't speak authoritatively for your system, but nohup really should not make a difference either way. Nohup disinherits a process from its ordinary parent and causes init to adopt it. Thus, you can see here:

Code:
RAID-Server:/usr/share/sensors# /etc/init.d/pyTivo restart
Restarting pyTivo Multimedia Server: pyTivo.
RAID-Server:/usr/share/sensors# ps -ef | grep pyT
root     29042     1  3 20:39 pts/4    00:00:00 /usr/bin/python2.6 /usr/share/pyTivo/pyTivo.py
RAID-Server:/usr/share/sensors# echo $$
3960
The pyTivo process is owned by PID 1, not the current shell (PID 3960 in this case). It should also cause the process to ignore a HUP (-1) signal. I believe it will still respond to all other signals in whatever fashion it has been designed to do. The Term signal (-15) should work normally, and the Kill signal (-9) cannot be blocked, so it should definitely work normally. (This is why the nohup command should not prevent sudo or login from killing an inactive shell.)

Edit:

Come to think if it, since this is going to be run from an init script, the daemon startup utility in your system should have an option to run as another user. In Debian derivatives, the start-stop-daemon utility simply uses the -c <user> option to accomplish this. The equivalent utility may be startproc -u <user> or something similar on your system. You still should use nohup, re-directing the output (both stdout and stderr) to either /dev/null or a log file, and terminate the line with "&" in order to spawn the utility in the background.
 

·
Registered
Joined
·
6,933 Posts
Oh, BTW, kill -9 is generally a rather nasty thing to do, and should be reserved for times when a process is well and truly hung. A much better practice for stopping well behaved processes in general is to use the TERM signal (-15), rather than the KILL signal (-9). It produces an orderly shutdown of the process and its children.
 

·
Registered
Joined
·
74 Posts
Thanks lrhorer, I could not get sudo to work from a rc.d script, it would work from the command line but not the script, so after pulling out my remaining hair I tried su and that got HMEVLC up and running using a rc.d script but vlc is now erroring out when starting a stream that requires vlc when I start HMEvlc through the script with su (ps if I start hmevlc at the command line using su things work fine with streams requiring vlc ??). I will look at my stdout and stderr file over the weekend to see if it provides any hints for what is going on. Appreciate the tip on kill -15.
 

·
Registered
Joined
·
74 Posts
Okay did some testing this morning before coming into work. My STDOUT and STDERR log is below. I start HMEVLC using the script with su as discussed above. The first time I try and stream a video requiring vlc to transcode I get the output below (see Try 1) in my STDOUT/STDERR log. From a HMEVLC perspective on the Tivo it just hangs. I then get out of HMEVLC on the Tivo, go back into HMEVLC and try and stream the same video and it comes back and says error trying to read the stream (as opposed to hanging) and get the following output below (see Try 2) in my STDOUT/STDERR log.

Also please note I use dbus-launch in vlc.py as this is running on a NAS. Finally if I start HMEVLC from the command line versus my init script using su things work fine. Not sure if any one has any further ideas?

Code:
Try 1-----------------------------------------------------------------------------------------------------------------------

192.168.0.4:53966 - - [21/Dec/2012 06:16:30] "GET /hmevlc/ HTTP/1.1" 200 -
192.168.0.4:53966 - - [21/Dec/2012 06:16:30] Starting HME: hmevlc
Traceback (most recent call last):
  File "/opt/lib/python2.6/SocketServer.py", line 560, in process_request_thread
    self.finish_request(request, client_address)
  File "/opt/lib/python2.6/SocketServer.py", line 322, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/local/hmeforpython/start.py", line 141, in __init__
    client_address, server)
  File "/opt/lib/python2.6/SocketServer.py", line 617, in __init__
    self.handle()
  File "/opt/lib/python2.6/BaseHTTPServer.py", line 329, in handle
    self.handle_one_request()
  File "/opt/lib/python2.6/BaseHTTPServer.py", line 323, in handle_one_request
    method()
  File "/usr/local/hmeforpython/start.py", line 232, in do_GET
    self._page(True)
  File "/usr/local/hmeforpython/start.py", line 186, in _page
    appinst.mainloop()
  File "/usr/local/hmeforpython/hme.py", line 1139, in mainloop
    while self.active and self.get_event():
  File "/usr/local/hmeforpython/hme.py", line 1236, in get_event
    handle(resource, status, info)
  File "/usr/local/hmeforpython/hmevlc/hmevid.py", line 220, in handle_resource_info
    self.retry_or_quit()
  File "/usr/local/hmeforpython/hmevlc/hmevid.py", line 206, in retry_or_quit
    self.start_vlc()
  File "/usr/local/hmeforpython/hmevlc/hmevid.py", line 80, in start_vlc
    vlc.start(self.item['url'])
  File "/usr/local/hmeforpython/hmevlc/vlc.py", line 77, in start
    pid = subprocess.Popen(['dbus-launch', vlcpath, url, '-I', 'dummy', '-V', 'dummy', '--sout', PARAMS % globals()]).pid
  File "/opt/lib/python2.6/subprocess.py", line 623, in __init__
    errread, errwrite)
  File "/opt/lib/python2.6/subprocess.py", line 1141, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory


Try 2-----------------------------------------------------------------------------------------------------------------------

192.168.0.4:38917 - - [21/Dec/2012 06:28:52] "GET /hmevlc/ HTTP/1.1" 200 -
192.168.0.4:38917 - - [21/Dec/2012 06:28:52] Starting HME: hmevlc
192.168.0.4:38917 - - [21/Dec/2012 06:29:27] Ending HME: hmevlc
PS. Is it normal that the port changed between try 1 and try 2?
 

·
Well-Known Mumbler
Joined
·
12,532 Posts
Discussion Starter · #456 ·
File "/opt/lib/python2.6/subprocess.py", line 1141, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
Well, that seems pretty clear-cut. It's not finding your VLC. Again.

PS. Is it normal that the port changed between try 1 and try 2?
Yes.
 

·
Registered
Joined
·
74 Posts
I finally got things (mostly) working and now use HMEVLC to view a couple of Foscam Cameras I have in the house as a baby monitor. I thought I would document my installation mods to make this work on a Synology NAS in case others have a similar issue (as well to document it in case I have to repeat the install one day!!):

1. Install VLC on the Synology NAS: The easiest way to do this is to bootstrap ipkg onto the Synology machine and then install vlc (see Synology wiki and forums for help with this).

2. Install python using ipkg or one of the Synology packages.

3. Install the HMEVLC python modules per the instructions at: https://github.com/wmcbrine/hmevlc

4. Add a line to config.ini under [hmevlc] telling HMEVLC to use cvlc versus vlc as this is a headless NAS: vlc=/opt/bin/cvlc

5. Set up scripts to automatically start HMEVLC:
Add the following script to /usr/local/etc/rc.d
Code:
#!/bin/sh
#
# Startup script for HME for Python

HMEFORPYTHON=/usr/local/hmeforpython/start.py

case "$1" in

start)
	if [ -x "$HMEFORPYTHON" ] ; then
		sleep 30
		echo "Starting HME for Python..."
		su admin -c sh -c '/usr/bin/nohup /usr/local/hmeforpython/hmeforpython_start.sh > /usr/local/hmeforpython/scrpt_log 2>&1 &'
	fi
	;;

stop)
	echo "Stopping HME for Python......."
	kill -9 `ps |grep hmeforpython/start.py | awk -F" " '{print $1}'` > /dev/null 2>&1
	;;

*)
	echo "usage: $0 { start | stop }" >&2
	exit 1
	;;

esac
The script above uses su to run under user admin as vlc will not work under root. Then add the following script at /usr/local/hmeforpython which is where I keep my hmevlc python files and scripts:
Code:
cd /usr/local/hmeforpython
/opt/bin/python /usr/local/hmeforpython/start.py > /usr/local/hmeforpython/hmevlc_log 2>&1 &

6. Change vlc.py [both start () and stop()] so that it launches vlc using dbus and it terminates the vlc pid versus the dbus pid:
Code:
def start(url):
    """ Increment the client count, and start VLC if this is the first
        client.

    """
    global client_count, pid
    client_count += 1
    if client_count == 1:
	pid = subprocess.Popen(['/opt/bin/dbus-launch', vlcpath, url, '-I', 'dummy', '-V', 'dummy', '--sout', PARAMS % globals(), 
':sout-mux-caching=150000', '--sout-keep']).pid
        # Give VLC a little time to start up before the request.
	time.sleep(2)

def stop():
    """ Decrement the client count, and stop VLC if this was the last
        client.

    """
    global client_count, pid
    if client_count:
        client_count -= 1
        if not client_count:
            if sys.platform == 'win32':
                import ctypes
                handle = ctypes.windll.kernel32.OpenProcess(1, False, pid)
                ctypes.windll.kernel32.TerminateProcess(handle, -1)
                ctypes.windll.kernel32.CloseHandle(handle)
            else:
                import os
                import signal
                os.kill(pid, signal.SIGINT)
                vlcpidps = subprocess.Popen(['ps', '-w'], stdout=subprocess.PIPE)
		out, err = vlcpidps.communicate()
		for line in out.splitlines():
  			if 'vlc' in line:
				vlcpid = int(line.split(None, 1)[0])
				os.kill(vlcpid, signal.SIGKILL)

I am sure my stop () vlc code is probably heavy handed but it works and I am not a python programmer so best I can do, as I said it works. I also mentioned at the start of the post that it mostly works. My remaining issue is that the stream will freeze after a few minutes, I suspect this is a vlc issue as my log shows vlc working and providing a stream and my NAS only maxes out at 16% CPU use but it is frozen when watching on the Tivo, see log below:

Code:
[00000001] main libvlc debug: translation test: code is "C"
[00000361] dummy interface: using the dummy interface module...
[00000377] main access out: creating httpd
[00000381] mux_ps mux: Open

I am running vlc 0.9.9a-2 which I know is an old version but that is what is installed when using the Synology ipkg Package Management system unfortunately. If someone can confirm this is definitely a vlc issue I might spend the time trying to compile a later version of vlc but right now I only need to watch the cameras for a minute at a time so will only try and compile a new version of vlc if I am sure it will fix the remaining issue.

Thanks for the help and support on getting this far.
 

·
Registered
Joined
·
74 Posts
Looking for some guidance on editing the HMEVLC python code to enable me to use HMEVLC to stream output from a number of new IP video cameras I now have attached to my home network to my Tivo using HMEVLC. I have the URL to add to the config.ini file along the lines of: http://ipaddress: port/url-stream/cameraName that provides me access to the camera stream and I have added it to the HMEVLC config file.

My problem is my cameras require a separate http url / get command to authenticate myself to the camera before the previous URL will work, along the lines of: http://ipaddress:port/url-authitcation/cameraName&usr=USERID&pwd=PASSWORD .

How can I edit the Python code to do the authentication call before it calls for the stream. Ultimately I would like to add a line to the config.ini file along the lines of 'authneeded=http://ipaddress:port/url-authitcation/cameraName&usr=USERID&pwd=PASSWORD' for each stream needing authentication and then change the Python code to issue the authentication get/http command if required per the config.ini file.

Any thoughts on where to start? I am a complete Python novice so go easy on me.
 
441 - 460 of 481 Posts
This is an older thread, you may not receive a response, and could be reviving an old thread. Please consider creating a new thread.
Top