[Index] [TitleIndex] [WordIndex

There is a lot which can be done with freevo. This page should help you to tweak freevo and enhance its use with usefull additional scripts. Sometimes features are more in how you use what you have than adding new options.

Tips and tricks aimed at extending the potential sources of multimedia data are presented on page TipsAndTricks_MediaSources.

Feel free to add scripts and hints here, that you like to share with other freevo users.

General

Using submount instead of automount

Everyone knows the behaviour of automount: You put in a CD or DVD and it gets automaticly mounted. When finished using the CD, you can't use the eject button, because the CD (DVD) is still mounted. Without a supplementary umount command or rebooting (rebooting in linux ???) you can't get the CD out of the tray.

If you're only intention is to use the PC for freevo, it's recommended to disable any automatic mounting of the DVD/CD player. Freevo is capable to handle this itself. Most distributions come with automount activated by default. Most likely this will happen from /etc/fstab.

Otherwise you could use submount.

http://sourceforge.net/projects/submount/

Download it from the download section and execute the installation instructions with care. There is a kernel module to be loaded and a aditional program part to be installed. Both need to be compilled from source.

The loaded kernel module:

[root@localhost freevo]# lsmod
Module                  Size  Used by
subfs                   9088  0

This part has been tested on Fedora Core 4 and Fedora Core 2

You need to stop automount

 service autofs stop 

and prevent the autofs service from being started ay boot time: use ntsysv

Modify the /etc/fstab file in the following way

# original line
#/dev/hda                /media/cdrecorder       auto    pamconsole,exec,noauto,managed 0 0
# install subfs
# This part is a shameless copy/paste out of subfs docs for easy review
#/dev/scd0 /cdrom udf:iso9660 ro,noauto,owner 0 0
#   becomes
#/dev/scd0 /cdrom subfs fs=udf:iso9660,ro 0 0
# The working line:
/dev/hda /media/cdrecorder subfs fs=udf:iso9660,ro 0 0

(my dvd is /dev/hda)

submount will automaticly umount the dvd when not in use anymore. The eject button of the dvd- or cdrom drive should work without extra interference. The DVD tray should behave as it was powered by a commercial product. Mandriva has default supermount installed with works the same.

Enable blanking screen with freevoscreensaver - turn off your display to save money and lower global warming :)

With all the Globalwarming some might want the screen go into powersave mode when it is not used (Radio, Mp3 ...). This can easily be done by using the script mode in the freevoscreensaver. Make sure that your local_conf.py has following setting for the freevoscreensaver.

plugin.activate('freevoscreensaver', args=('script','/home/freevo/.freevo/sleep.sh','/home/freevo/.freevo/wake.sh',))

#SSAVER_DELAY: Number of seconds to wait to start screensaver.
SSAVER_DELAY=60

#SSAVER_POLL: Number of seconds to wait between polling.
SSAVER_POLL=120

in the above case the system will check every 120 seconds if the system has been idle for more than 60 seconds. If idle time is higher than 60 seconds at the check it will call script "sleep.sh".

Script sleep.sh can look as simple as:

xset dpms force off

And once an event happens the script "wake.sh" is called.

The script wake.sh can look as simple as:

xset dpms force on

Setting the time from the DVB signal

There is a small program called 'dvbdate' in the dvb-utils package, which can be used to set the system time from the dvb signal. For that purpose you must tune your dvb card to an appropriate channel and run dvbdate -s as root.

I have a small script which is executed during boot up:

# tune the dvb card to an channel
tzap -c /etc/channels.conf ZDF&

#this stops the script when tzap could not be launched
#(maybe the dvb device is not ready)
if ps |grep $! >/dev/null;then

# start dvbdate
dvbdate -sf

# kill the tuning process
kill $!
fi

Of course you must use the right 'zap' application for your kind of DVB (tzap, szap or czap). And replace ZDF with the name of one of your channels.

Video

Generate thumbnails for all your videos

If you have just started using freevo or have a bunch of new videos you've just added to your collection you can have freevo automatically generate thumbnails for all of them by running:

freevo cache --thumbnail --recursive /path/to/videofiles

Getting IMDB info for all your movies

If you've got a bunch of movies you've just added to your collection you can run the following script to lookup and download IMDB information for all of them:

COD=`freevo imdb -s "$1" | tail -n1 - | grep -o "[0-9]* "`
freevo imdb $COD "$1" "$1.avi"

A second solution is possible. It is very similar but it takes only the first result instead of the last in case of many suggestions. That is more accurate because the most reliable result are placed in first position.

COD=`freevo imdb -s "$1" | grep -o -E "[0-9]{7} " | head -n1`
freevo imdb $COD "$1" "$1.avi"

Transcoding shows that are recorded from DVB

Note: You may find this easier using mencoder, TV_REENCODE or the EncodingServer and video.reencode plugin

After programs have been recorded, you can transcode them to save some space. Here's one that I use to transcode to ogm. I'm using ogm since you need to extract the audio to normalize it anyway, so I might as well use the ogg container. The other thing to note is the -mc 10, which tells mencoder to trust the A/V sync in the input stream, rather than trying to correct the sync itself.

This video bitrate is rather high for the size, it will probably work just as well at 800kbit.

NICE="20"
VBITRATE="1100"
AQUALITY="3"

VCODEC_OPTS="vbitrate=$VBITRATE:vhq:keyint=250"
ACODEC_OPTS="preset=$ABITRATE"

VFILTER="pp=fd,scale=480:272"

EXTRA_OPTS="-aspect 16:9 -mc 10"

WAV_FILE="${1}.wav"
OGG_FILE="${1}-audio.ogg"
AVI_FILE="${1}-video.avi"

rm -f frameno.avi "$WAV_FILE" "$OGG_FILE" "$AVI_FILE"

nice -n $NICE mencoder ${EXTRA_OPTS} -ovc frameno -oac copy -o frameno.avi "$1"                                               && \
nice -n $NICE mplayer  ${EXTRA_OPTS} -vc dummy -vo null  -hardframedrop -ao pcm -aofile "$WAV_FILE" "$1"                      && \
nice -n $NICE normalize "$WAV_FILE"                                                                                           && \
nice -n $NICE oggenc "-q${AQUALITY}" "-o${OGG_FILE}" "${WAV_FILE}"                                                            && \
nice -n $NICE mencoder ${EXTRA_OPTS} -vf $VFILTER -ovc lavc -lavcopts ${VCODEC_OPTS}:vpass=1 -oac copy -o /dev/null "$1"      && \
nice -n $NICE mencoder ${EXTRA_OPTS} -vf $VFILTER -ovc lavc -lavcopts ${VCODEC_OPTS}:vpass=2 -oac copy -o "${AVI_FILE}" "$1"  && \
nice -n $NICE ogmmerge -o "$2" -A "$AVI_FILE" "$OGG_FILE"                                                                     && \
rm -f divx2pass.log frameno.avi "$WAV_FILE" "$OGG_FILE" "$AVI_FILE"                                                           || \
( echo "Transcode Failed" && \
exit 10 )

# done
echo "Transcode Successful"

Note: To create an avi from the above change the oggenc line to be as below

nice -n $NICE lame -q ${AQUALITY}  "${WAV_FILE}" "${OGG_FILE}"

and the ogmmerge line to use avimerge (found in the transcode package) as show below

nice -n $NICE avimerge -o "$2" -i "$AVI_FILE" -p "$OGG_FILE" -A 0

Here's another script I use to generate the thumbnails:

INPUT="$1"
OUTPUT="$2"

TEMPFILE="/tmp/thumnailer$$"

nice -n 20 transcode -V -i "${INPUT}" -y jpg,null -o "${TEMPFILE}" -c 2000-2001
mv "${TEMPFILE}000000.jpg" "${OUTPUT}"

This one is a daemon I start at boot time to monitor the recordings directory and transcode the files after the capture is complete. It also updates the FXD with the extension of the transcoded file.

CAPTURE_EXTENSION="ps"
TRANSCODED_EXTENSION="ogm"
THUMBNAIL_EXTENSION="jpg"

TRANSCODER="${HOME}/commands/transcoder"
THUMBNAILER="${HOME}/commands/thumbnailer"


RECORDING_DIR="${HOME}/recordings"

cd "$RECORDING_DIR"

while ((1)) ; do
        echo Sleeping
        sleep 300
        echo Waking up
        date
        for CAPTURED_FILE in `find . -mmin +5 -name "*.${CAPTURE_EXTENSION}"` ; do
                echo "Processing File ${CAPTURED_FILE}"
                TRANSCODED_FILE=`echo ${CAPTURED_FILE} | sed "s/${CAPTURE_EXTENSION}\$/${TRANSCODED_EXTENSION}/"`
                FXD_FILE=`echo ${CAPTURED_FILE} | sed "s/${CAPTURE_EXTENSION}\$/fxd/"`
                THUMBNAIL_FILE=`echo ${CAPTURED_FILE} | sed "s/${CAPTURE_EXTENSION}\$/${THUMBNAIL_EXTENSION}/"`
                echo "Transcoded File is ${TRANSCODED_FILE}"

                if [ -e ${TRANSCODED_FILE} ] ; then
                        echo "Transcoded file already exists! - deleting it"
                        rm "${TRANSCODED_FILE}"
                fi
                echo "Transcoding file ${CAPTURED_FILE}"

                ${TRANSCODER} "${CAPTURED_FILE}" "${TRANSCODED_FILE}"

                if [ $? = 0 ] ; then
                        echo "Transcoding Success"

                        if [ -e ${FXD_FILE} ] ; then
                                echo "Fixing FXD"
                                sed -i "s/\\.${CAPTURE_EXTENSION}/\\.${TRANSCODED_EXTENSION}/" "${FXD_FILE}"
                        fi

                        ${THUMBNAILER} "${TRANSCODED_FILE}" "${THUMBNAIL_FILE}"

                        echo "Deleting ${CAPTURED_FILE}"
                        rm -f "${CAPTURED_FILE}"
                else
                        echo "Failed to transcode ${CAPTURED_FILE} !!!"
                        rm "${TRANSCODED_FILE}"
                fi
        done
done

Hopefully that will give you a starting point to create your own transcoding setup.

Starting Freevo (X11) without a mouse

If you are running Freevo in X11, and you dont have/want a mouse installed on the computer; you can tell X11 to ignore the mouse if it cant open the device. The option is called AllowMouseOpenFail and it is a server boolean option. To enable this feature, open up the XF86Config-4 file and add that as an option. The best part is that if you connect a mouse later, it will work without any changes.

cat /etc/X11/XF86Config-4
...
Section "ServerLayout"
    Screen    "Default Screen"
    Option    "AllowMouseOpenFail"    "true"
...
EndSection

Get rid of blue borders (playing movies/tv)

To get rid of blue borders while playing movies or watching tv you can use the following tool:

/usr/bin/xvattr -a XV_COLORKEY -v 0

It turns the blue borders black. This problem appears with XV video out mode. To start this command on freevo startup, set

OSD_SDL_EXEC_AFTER_STARTUP = "/usr/bin/xvattr -a XV_COLORKEY -v 0"

in your local_conf.py. Optionally you can start your own script with multiple commands on startup.

* I don't completely understand why, but in order for this to work on my system (geforce 2), I first have to issue the following command (hopefully this helps someone else who is having trouble):

/usr/bin/xvattr -a XV_AUTOPAINT_COLORKEY -v 1

Making your DVDs plays smoothly

If your DVD playback is erratic or it stops after a few seconds and then starts again, your DVD drive might not be working at optimal speed; DMA transfer may be disabled, etc.

You can fix that problem by running this command as a root:

** DANGEROUS **

/sbin/hdparm -d1 -X66 /dev/dvd

The above command has a dangerous mark next to it in the usage, I (KarlLattimer) was recommended to use this command by the xine website on improving performance, however my DVD drive has just kicked the bucket because of repeated use of changing the xfer mode of the drive, some drives may not have problems with this, I believe it may only be dangerous if there is a disc in the drive at the time, but after killing my drive I wouldn't want to take the chance again.

** less dangerous **

/sbin/hdparm -d1 /dev/dvd

This command seems to be adequete, and doesn't have any dangerous mark.

You can tweak the settings by looking up the hdparm documentation.

To make it permanent add it to your startup scripts (eg. /etc/init.d etc.).

Images

Creating slideshows from a bunch of images

This might help you to create a slide show from a couple of images. It is just a bit of bash code:

echo "[Slides]" > blah.ssr; ls -B -I \*.ssr | perl -ln -e 'print "FileName: \"$_\"; Caption: \"Image\"; Delay: \"5\";"' >> blah.ssr

This shall be a single line. Note the ' before print, the ending one is just before >> blah.ssr It will create a slideshow file, in the current directory, called blah.ssr that contains all files in the current directory EXCEPT *.ssr and *~ - if you do not desire this, remove the -B from the ls command. The delay is here set to 5 seconds, but you can change that number. To change the output file, just change the blah.ssr references to <what you want it to be called>.ssr. You can change the default Caption and Image, to whatever you like, but be mindful of the quotemarks.

Audio

Normalize mplayer Audio Output

For the user running as freevo, put this in their ~/.mplayer/config to normalize the audio output:

-aop=list=volnorm

Digital audio output to two devices

If you have a media centre PC, then chances are you will want audio output to more than one output on your sound card. In my case I had the LCD TV that was fed via HDMI as well as an AV Amplifier fed via the optical SPDIF output.

It is useful to configure a sound output that will output the sound via HDMI and via the SPDIF for normal audio and video playback. This allows music to be played and then the TV switch off for listening via the AMP. For TV films the Amplifier can be used in Dolby Pro Logic mode. For normal TV watching you can just use the TV's own speakers.

To do this you can create a new ALSA device, which takes the audio input from the program playing the audio (e.g. mplayer) and then duplicates this output between the 2 different outputs. This can be used as by mplayer using the following -ao option:

mplayer -ao alsa:device=both

Add the following to your /etc/asound.conf file, or your users .asoundrc file to create a new "both" device. NOTE: This only configures stereo sound.

pcm.both {
         type route
         slave {
                 pcm multi
                 channels 4
         }
         ttable.0.0 1.0
         ttable.1.1 1.0
         ttable.0.2 1.0
         ttable.1.3 1.0
}

pcm.multi {
         type multi
         slaves.a {
                 pcm "tv"
                 channels 2

         }
         slaves.b {
                 pcm "receiver"
                 channels 2
         }
         bindings.0.slave a
         bindings.0.channel 0
         bindings.1.slave a
         bindings.1.channel 1
         bindings.2.slave b
         bindings.2.channel 0
         bindings.3.slave b
         bindings.3.channel 1
}

pcm.tv {
         type hw
         card 0
         device 3
         channels 2
}

pcm.receiver {
         type hw
         card 0
         device 1
         channels 2
}

The correct card and device for the "pcm.tv" and "pcm.receiver" sections can be found by running aplay -l:

[root@lounge ~]# aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: NVidia [HDA NVidia], device 0: VT1708S Analog [VT1708S Analog]
  Subdevices: 2/2
  Subdevice #0: subdevice #0
  Subdevice #1: subdevice #1
card 0: NVidia [HDA NVidia], device 1: VT1708S Digital [VT1708S Digital]
  Subdevices: 2/2
  Subdevice #0: subdevice #0
  Subdevice #1: subdevice #1
card 0: NVidia [HDA NVidia], device 3: NVIDIA HDMI [NVIDIA HDMI]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

In this case both outputs are on card 0 (although you could use 2 different sound cards if you wanted). The "pcm.receiver" is the digital output on device 1 and "pcm.tv" is the HDMI output on device 3.

TV

Add Live stream TV with station switching without stream interruption to your Freevo website (www plugin)

Basically you have an extra tab on you Freevo website, from which you can watch via live stream your own TV anywhere over the Internet and switch channles/stations without the necessisty to stop or restart the stream. You can still follow the description below, but I have created a script, which basically does all that what you would have to do down there for you. Just download this zip file.

First you will need an extra tab on the site, this can now be done in the local_conf.py in the following section:

Integrate personal web pages into the web server
PERSONAL_WWW_PAGE = [
    ('LiveTV', 'Watch live TV', 'test.rpy')
]

Now there should be an extra tab called 'LiveTV' on your site (once you reload the loca_conf.py of course). The next step is about creating the content of the 'test.rpy', which will enables us to initiate and also stop (to save CPU power and memory when not used) several (or one) streams at once. I also included an embedded mediaplayer, so far prooven to work in IE and Firefox. All the '*.rpy' files, which you will have to create have to be located in 'htdocs' directory, this is also where all the other '*.rpy' for the freevo website are kept.

The 'test.rpy' should look like this:

# -----------------------------------------------------------------------
# Freevo - A Home Theater PC framework
# Copyright (C) 2002 Krister Lagerstrom, et al.
# Please see the file freevo/Docs/CREDITS for a complete list of authors.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MER-
# CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# -----------------------------------------------------------------------
import sys
import os
from www.web_types import HTMLResource, FreevoResource

class TestResource(FreevoResource):

    def _render(self, request):
        fv = HTMLResource()
        fv.printHeader(_('LiveTV'), 'styles/main.css',selected=_('Test'))
        form = request.args
        fv.res += "<html>To start the stream server click <a href=\"http://your_ip:port/startstream.rpy\" _fcksavedurl="\"http://your_ip:port/startstream.rpy\"" target=\"_blank\">here.</a> To stop the stream-server click<a href=\"http://your_ip:port/stopstream.rpy\">here.</a> To switch to the station you can simply click on the station you want to watch. A new window will pop up and close itself automatically, then the station should be changed.</html>"
        fv.res += "<html><a href=\"MTV.rpy\" target=\"_blank\">MTV</a> <a href=\"TMF.rpy\" target=\"_blank\">TMF</a> <a href=\"national.rpy\" target=\"_blank\">National Geographic</a> <a href=\"discovery.rpy\" target=\"_blank\">Discovery Channel</a> <a href=\"CNN.rpy\" target=\"_blank\">CNN</a> <a href=\"BBC1.rpy\" target=\"_blank\">BBC1</a> <a href=\"BBC2.rpy\" target=\"_blank\">BBC2</a> <a href=\"net5.rpy\" target=\"_blank\">Net5</a> <a href=\"sbs6.rpy\" target=\"_blank\">sbs6</a> <a href=\"veronica.rpy\" target=\"_blank\">Veronica</a> <a href=\"talpa.rpy\" target=\"_blank\">talpa</a> <a href=\"rtl4.rpy\" target=\"_blank\">rtl4</a> <a href=\"rtl5.rpy\" target=\"_blank\">rtl5</a> <a href=\"rtl7.rpy\" target=\"_blank\">rtl7</a> <a href=\"een.rpy\" target=\"_blank\">een</a> <a href=\"euronews.rpy\" target=\"_blank\">Euronews</a> <a href=\"ard.rpy\" target=\"_blank\">ARD</a> <a href=\"zdf.rpy\" target=\"_blank\">ZDF</a> <a href=\"wdr.rpy\" target=\"_blank\">WDR</a> <a href=\"gelderland.rpy\" target=\"_blank\">TV Gelderland</a> <a href=\"ned1.rpy\" target=\"_blank\">Nederland 1</a> <a href=\"ned2.rpy\" target=\"_blank\">Nederland 2</a> <a href=\"ned3.rpy\" target=\"_blank\">Nederland 3</a> <a href=\"ketnet.rpy\" target=\"_blank\">Ketnet/Canvas</a> <a href=\"lokal.rpy\" target=\"_blank\">Lokaal Plus</a> <a href=\"upcinfo.rpy\" target=\"_blank\">UpcInfo</a> <a href=\"trtint.rpy\" target=\"_blank\">TRTint</a> <a href=\"rai1.rpy\" target=\"_blank\">Rai Uno</a> <a href=\"eurosport.rpy\" target=\"_blank\">Eurosport</a> <a href=\"nick.rpy\" target=\"_blank\">Nick/Comedy Central</a> <a href=\"tellsell.rpy\" target=\"_blank\">TellSell</a> <a href=\"tv5.rpy\" target=\"_blank\">TV5</a> <a href=\"cam.rpy\" target=\"_blank\">cam</a></html>"
        fv.res += "<center><OBJECT ID=\"MediaPlayer\" WIDTH=320 HEIGHT=300 CLASSID=\"CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95\" STANDBY=\"Loading Windows Media Player components...\" TYPE=\"application/x-oleobject\" /><param name=\"autoStart\" value=\"true\" /><PARAM NAME=\"error\" VALUE=\"item\" /><PARAM NAME=\"stretchToFit\" VALUE=\"false\" /><PARAM NAME=\"ShowStatusBar\" VALUE=\"true\" /><PARAM NAME=\"FileName\" VALUE=\"mms://your_ip:port\" /> <EMBED TYPE=\"application/x-mplayer2\" SRC=\"mms://your_ip:port\"NAME=\"MediaPlayer\" WIDTH=320 HEIGHT=300 ShowStatusBar=\"1\" /></EMBED></OBJECT></center>"
        return String( fv.res )
resource = TestResource()

The 'test.rpy' first gives you a link to start and stop a vlc stream '...<a href=\"http://your_ip:port/startstream.rpy...' and '...To stop the stream-server click<a href=\"\...' You have to fill in your IP and port on which your Freevo webserver is running (default Freevo webserver port is 8080). The content of the 'startstream.rpy' and 'stopstream.rpy' is given furhter down below. In the 'test.rpy' you can see all the stations that I can receive. I put them as links on my site, which then in turn (when clicked of course) executes a command and switches the station (window pops up and closes automatically again). The links inside the 'test.rpy' are build like this: '...<html><a href=\"MTV.rpy\" target=\"_blank\">MTV</a> ...' so for each station you can receive you have to create an entry like this one and then also create that *.rpy file accordingly, so in this case 'MTV.rpy'. The example 'MTV.rpy' is shown further below.

which are actually two streams at ones, one is a http stream the other a mms stream next to it there are links to e.g. MTV.rpy which enables you to switch the channel from the current one to (in this example) MTV withouth interupting the stream, when clicked on the link MTV.rpy another window pops up, execute the channel switching command and closes afterwards below the links there is an embedded mediaplayer for internet explorer and should also work in firefox in which you should be able to view the stream, alternatively the stream can also be opened in vlc via the http stream, using e.g. http://your_ip:port the port settings depend on what you set when the vlc stream command is executed, this happens in the file 'startstream.rpy' which is shown below:

This is the script to start the vlc stream server. It will initiate two streams at ones, one is a http stream, which you can open with an external application like e.g. vlc and the other stream is a mms stream, which should play in the embedded player. Of course you can adjust these by changing the vlc command in the 'startstream.rpy'.

The 'startstream.rpy' should look like this:

# -----------------------------------------------------------------------
# Freevo - A Home Theater PC framework
# Copyright (C) 2002 Krister Lagerstrom, et al.
# Please see the file freevo/Docs/CREDITS for a complete list of authors.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MER-
# CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# -----------------------------------------------------------------------
import sys
import os
from www.web_types import HTMLResource, FreevoResource

class TestResource(FreevoResource):

    def _render(self, request):
        fv = HTMLResource()
        fv.printHeader(_('LiveTV'), 'styles/main.css',selected=_('Test'))
        form = request.args
        command = "vlc v4l:/dev/video0:norm=pal:frequency=767250:size=320x240:channel=0:adev=/dev/dsp:audio=0 --sout \'#transcode{vcodec=DIV3,vb=3000,scale=1,acodec=mp3,ab=256,channels=2}:duplicate{dst=std{access=http,mux=ts,url=your_ip:port},dst=std{access=mmsh,mux=asfh,dst=:port}}\' -I dummy&"
        os.system(command)
        fv.res += "<html><script language=\"JavaScript\"> close();</script></html>"
        return String( fv.res )
resource = TestResource()

The script above starts the vlc stream, when clicked on the link a window will pop up and close itself afterwards. Here you should set your ip and port in the sections where you have to ('url=your_ip:port' and 'dst=:port'). You should also make sure that you adjust your video and audiodevice accordingly (e.g. my TVcard is on '/dev/video0' hence I have 'vlc v4l:/dev/video0...'. It is also important that the user, as which you run the Freevo webserver, as permissions to your video and audio device! Additionally, you can set the encoding/streaming options you want vlc to use. At some point you might want to turn of the vlc stream. As I said in my case it eats up too much CPU power and memory, so I always stop it when I'm done.

The 'stopstream.rpy' should look like this:

# -----------------------------------------------------------------------
# Freevo - A Home Theater PC framework
# Copyright (C) 2002 Krister Lagerstrom, et al.
# Please see the file freevo/Docs/CREDITS for a complete list of authors.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MER-
# CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# -----------------------------------------------------------------------
import sys
import os
from www.web_types import HTMLResource, FreevoResource

class TestResource(FreevoResource):

    def _render(self, request):
        fv = HTMLResource()
        fv.printHeader(_('LiveTV'), 'styles/main.css',selected=_('Test'))
        form = request.args
        command = "killall vlc"
        os.system(command)
        fv.res += "<html>Streamserver is shutdown.</html>"
        return String( fv.res )
resource = TestResource()

Next you will need the station links we discussed earlier. I will continue with the 'MTV.rpy' example, which you can use as a template for all other stations you have. For each station you have, you will also need the 'stationname.rpy' equivalent and put it with that name in the 'test.rpy' as explained earlier.

The 'MTV.rpy' should look like this:

# -----------------------------------------------------------------------
# Freevo - A Home Theater PC framework
# Copyright (C) 2002 Krister Lagerstrom, et al.
# Please see the file freevo/Docs/CREDITS for a complete list of authors.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MER-
# CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# -----------------------------------------------------------------------
import sys
import os
from www.web_types import HTMLResource, FreevoResource

class TestResource(FreevoResource):

    def _render(self, request):
        fv = HTMLResource()
        fv.printHeader(_('LiveTV'), 'styles/main.css',selected=_('Test'))
        form = request.args
        command = "v4lctl setstation MTV"
        os.system(command)
        fv.res += "<html><script language=\"JavaScript\"> close();</script></html>"
        return String( fv.res )
resource = TestResource()

You will need a working 'v4lctl' command on your computer. This command usually comes with xawtv. You can test this command by opening any TV watching application and then run from the command line 'v4lctl setstation MTV' where you replace 'MTV' with a stationname you have. The station should switch in the TV watchin application to that channel once you executed the command. In order for 'v4lctl setstation MTV' to know how the stations are called you will need to have a working '.xawtv' config file, because the station names have to be identical with what has been specified in that file in order for 'v4lctl' to work, usually the file is located at: /home/user/.xawtv

An extract from my '.xawtv' looks like this:

[global]
ratio = 4:3
freqtab = europe-west
pixsize = 128 x 96
pixcols = 1
jpeg-quality = 75
keypad-ntsc = no
keypad-partial = yes
osd = yes
osd-position = 30 , 20
use-wm-fullscreen = yes

# [Station name]
# capture = overlay | grabdisplay | on | off
# input = Television | Composite1 | S-Video | ...
# norm = PAL | NTSC | SECAM | ...
# channel = #
# fine = # (-128..+127)
# key = keysym | modifier+keysym
# color = #
# bright = #
# hue = #
# contrast = #

[defaults]
group = main
norm = PAL
input = Television
capture = over
color = 74%

[MTV]
channel = 58
capture = on

[TellSell]
channel = 29
capture = on
fine = +9

[Discovery Channel]
channel = 62
capture = on

[TMF]
channel = 33
capture = on

[CNN]
channel = 56

[TV5]
channel = SE19
capture = on

You have to use the exact stationnames specified here in all the *.rpy. So the important thing here (in the '.xawtv') are the station names in the '[MTV]' brackets these we need for the 'v4lctl' command to work properly. So to recap, you need to create for each channel/station, which you want to be able to switch and appear as a link on your Freevo site, a *.rpy file like the MTV one so MTV.rpy, TMF.rpy, CNN.rpy and so on, with the same content, just the 'v4lctl setstation MTV' has to be adjusted to the channel name according to the .xawtv file.

Once you restart your Freevo and login to your website and go the 'LiveTV' tab you need first to start the live stream by clicking on the appropriate link on the site, then after a few seconds you can click on the play button on the embedded player and it should start to buffer and stream the TV, alternatively you can also open you vlc player if you have it installed and open a http network stream with your ip and port you specified in the 'startstream.rpy'. If you prefer having the stream start immedialty when you click on the 'LiveTV' tab then u need to include in the 'test.rpy' the part from 'startstream.rpy' (but I would suggest not to):

command = "vlc v4l:/dev/video0:norm=pal:frequency=767250:size=320x240:channel=0:adev=/dev/dsp:audio=0 --sout \'#transcode{vcodec=DIV3,vb=3000,scale=1,acodec=mp3,ab=256,channels=2}:duplicate{dst=std{access=http,mux=ts,url=your_ip:port},dst=std{access=mmsh,mux=asfh,dst=:port}}\' -I dummy&"
        os.system(command)

I'm sure somehow this could be done more efficient, especially with the python scripts, but I have never used python before, so if someone has suggestions to improve this, you are more then welcome, for now it works fine. I have tested this on an ubuntu feisty machine with Freevo 1.7.3.

Bash script to get xml data safely

I have had problems with XMLTV downloads failing, due to both the site being down, or corrupt data on the site. In the default setup, this deletes the current listings leaving a broken TV guide. The following script downloads the XML to a safe location, checks on the success of the download, and creates a link to this file in the location freevo checks only on success. It is designed for the UK radiotimes script; users in other locations may have to make small changes detailed below. However, this checks for a successful download in a stupid way; this script can certainly be improved and a careful read is advised!

The line starting {/usr/bin/tv_grab_uk_rt} will need modification for non-uk users. The initial number of days (initdays=14) may also need changing. If reducing the number of days does not work, the script tries to instead user a different config file for xmltv. I have had a problem "Code point \u0000 is not a valid character in XML" which seems to occur only for Film4 xml data, so I made a separate config file with Film4 removed ($HOME/.xmltv/tv_grab_uk_rt-nofilmfour.conf), as shown in the script. This is obviously irrelevent if you do not have Film4, or are not experiencing this code point problem.

The script is:

lfile=`date +"listings_%d%m%Y.xml"`
efile="/tmp/TV.xml_$lfile.error"
listings="$HOME/.freevo/xmltv/$lfile"
config="$HOME/.xmltv/tv_grab_uk_rt.conf"

initdays=14
deltadays=7
deleteafterdays=7

days=$initdays
try=1

mkdir -p "$HOME/.freevo/xmltv"

while [ $try -ne 0 ]; do
    echo "Using days=$days, config file $config"
    /usr/bin/tv_grab_uk_rt --output $listings --offset -1 --days $days --config-file \
$config 2>$efile
    result=`cat $efile | grep "Finished!"`
    if [ "x" = "x$result" ];then
        echo Failure to process file correctly
        if [ $try -lt $initdays ]; then
            days=$(($days - $deltadays))
            echo "Fail! Trying less days ($days) instead."
        fi
        if [ $days -le 1 ]; then
            config="$HOME/.xmltv/tv_grab_uk_rt-nofilmfour.conf"
            days=$initdays
            echo "Fail! Trying config $config instead."
        fi
        try=$(($try + 1))
        if [ $try -gt $(($initdays + 1)) ]; then
            try=0
            echo "I've given up trying to download listings!"
        fi
    else
        echo Successful update of $days days, with config file $config!
        rm /tmp/TV.xml
        ln -s $listings /tmp/TV.xml
        try=0
    fi
done


##### Clean up old files
find /tmp/TV.xml_* -maxdepth 0 -mtime +$deleteafterdays -exec rm '{}' \;
find $HOME/.freevo/xmltv/listings_*.xml -maxdepth 0 -mtime +$deleteafterdays -\
exec rm '{}' \;

Save this as executable, e.g. $HOME/freevo_get_channels.sh, and add it to your crontab via crontab -e:

02 20 * * *     /path/to/my/home/directory/freevo_get_channels.sh

Setup Hulu Desktop

Follow this link for detailed instruction on how to setup HuluDesktop.

HuluDesktop allows you to see all of Hulu, not just Hulu plus with a nice, "10 foot" interface.

Using the setup described, you will get a menu option for HuluDesktop, it will load, and then when you exit from HuluDesktop, Freevo will be back running.


2014-02-15 05:47