There is a lot which can be done with freevo. This page should help you to tweak freevo and enhance its use with useful additional scripts, in order to extend the potential sources of multimedia data.
Feel free to add scripts and hints here, that you like to share with other freevo users.
Contents
Get Daily Cartoons on your Freevo
(By Tom Van den Bon)
1. Create your own cartoons folder:
mkdir /pictures/cartoons
2. Edit your local_conf.py to point to your picture folder:
IMAGE_ITEMS = [ ('Cartoons', '/pictures/cartoons'), ... ]
3. After you have installed dailystrips use dailystrips -list to get a list of all available cartoons.
4. Create a script called getcartoons containing the following:
# get my fav cartoons dailystrips --local -stripdir -save -basedir /pictures/cartoons dilbert garfield thefifthwave
5. Add it to your cron jobs. Depending on your distro either add a link to it in your cron.daily or add a line like this to your crontab:
0 4 * * * /usr/local/bin/getcartoons
Dailystrips will put all the cartoons in their own respective directory and you can navigate it via the freevo interface.
Automount removable media
To automatically mount removable media (CDROMS, SD/MMC/MS cards, USB sticks,... and hot swap harddrives), I use halevt.
USB sticks and flash media
On my Kubuntu 10.04, the configuration file for halevt is located at /etc/halevt/halevt.xml. By Kubuntu default, halevt will automount all removable media with the option sync. It's much better to mount them read-only to avoid wearing on the media. To do so, modify the following lines in halevt.xml
<halevt:Device match="hal.block.device & hal.block.is_volume = true & (hal.volume.policy.should_mount = true | ((! hal.volume.policy.should_mount = false) & (hal.block.storage_device.hal.storage.policy.should_mount = true | ((! hal.block.storage_device.hal.storage.policy.should_mount = false) & (hal.block.storage_device.hal.storage.hotpluggable = true | hal.block.storage_device.hal.storage.removable = true)))))"> <halevt:Insertion exec="halevt-mount -u $hal.udi$ -o sync -m 002"/> </halevt:Device>
to
<halevt:Device match="hal.block.device & hal.block.is_volume = true & (hal.volume.policy.should_mount = true | ((! hal.volume.policy.should_mount = false) & (hal.block.storage_device.hal.storage.policy.should_mount = true | ((! hal.block.storage_device.hal.storage.policy.should_mount = false) & (hal.block.storage_device.hal.storage.hotpluggable = true | hal.block.storage_device.hal.storage.removable = true)))))"> <halevt:Insertion exec="halevt-mount -u $hal.udi$ -o ro -m 002"/> </halevt:Device>
Hot swap SATA harddrives
I also have a SATA internal dock where you can hot swap SATA harddrives. To make halevt mount these harddrives automatically upon insertion, I add the following lines to halevt.xml (Note that D8C6300BC62FE908 is the UUID of my harddrive partition. Replace this with your harddrive UUID). Do this for every SATA harddrive you have:
<halevt:Device match="hal.block.device & hal.volume.uuid = D8C6300BC62FE908 "> <halevt:Insertion exec="sudo halevt-mount -u $hal.udi$ -o ro -m 222"/> </halevt:Device> <halevt:Device match="hal.block.device & hal.volume.uuid = D8C6300BC62FE908 "> <halevt:OnInit exec="sudo halevt-mount -u $hal.udi$ -o ro -m 222"/> </halevt:Device>
Note: also make sure that you can run sudo halevt-mount without password. Add this line to your /etc/sudoers file:
halevt ALL=NOPASSWD:/bin/mount,/usr/bin/halevt-mount
Mounting remote fs's
A relative simple way to automount remote file systems is to use autofs. After install use the following config files.
cat /etc/autofs/auto.master # $Id: auto.master,v 1.1 2000/08/08 17:53:33 achim Exp $ # Sample auto.master file # Format of this file: # mountpoint map options # For details of the format look at autofs(8). /smbnet /etc/autofs/auto.smbnet --timeout=30 cat /etc/autofs/auto.smbnet # $Id: auto.misc,v 1.2 2002/10/27 05:21:15 bcowan Exp $ # This is an automounter map and it has the following format # key [ -mount-options-separated-by-comma ] location # Details may be found in the autofs(5) manpage #boot -fstype=ext2 :/dev/hda1 #cd -fstype=iso9660,ro :/dev/cdrom #floppy -fstype=auto :/dev/fd0 storage -fstype=smbfs,users,rw,username=someuser,password=somepass ://storage/Storage camera -fstype=auto,nosuid,nodev,noexec,user,gid=100,umask=000 :/dev/sda1
An entry /smbnet should show up in / dir when autofs is started from init.d. To make sure autofs is started correctly The output of 'ps ax | grep autofs' should be something like
5410 ? S 0:00 /usr/sbin/automount --timeout 30 /smbnet file /etc/autofs/auto.smbnet
cd to /smbnet/storage and it should automagicly mount the filesystem
After this edit local.conf.py and add the following in the VIDEO_ITEMS section or another ITEMS section if thats on your share.
VIDEO_ITEMS = [ ('Storage movies','storage:/smbnet/storage')]
Notice the hostname xp or storage before the path, it tries to ping the hostname and when succesfull the entry shows up in the menu, if not succesfull it doesn't show up and the filesystem isn't mounted.
Copy MythTV recordings into Freevo
If you've moved from MythTV to Freevo, there may be lots of recordings stored in MythTV's database which you want to have access to in Freevo. Although you can point Freevo at the MythTV recording directory, the names are fairly meaningless. The script below generates an FXD info file for each recording in the MythTV recording directory.
The FXDs can then be moved into a Freevo video directory to get full access to your MythTV recordings.
# # Connect to the MythTV database and produce FXD files for Freevo. # (c) Andrew Flegg 2007, released under the Artistic Licence. use warnings; use strict; use DBI; use XML::Writer; use Time::Local; use IO::File; use subs qw(t); my $user = ''; my $pass = ''; my $db = 'mythconverg'; my $host = 'localhost'; if (open(IN, "</etc/mythtv/mysql.txt")) { while(<IN>) { chomp(); my ($k, $v) = /^(\w+)=(.*)$/; $user = $v if $k =~ /DBUserName/i; $pass = $v if $k =~ /DBPassword/i; $db = $v if $k =~ /DBName/i; $host = $v if $k =~ /DBHostName/i; } close(IN); } $user ||= $ARGV[0]; $pass ||= $ARGV[1]; my $dbh = DBI->connect('DBI:mysql:mythconverg', $user, $pass); print "+++ Connected to database\n"; my $setting = $dbh->prepare('SELECT data FROM settings WHERE value = ?'); my $prog = $dbh->prepare('SELECT title, subtitle, description FROM recorded WHERE chanid = ? AND starttime = ?'); $setting->execute('RecordFilePrefix'); my $prefix = (($setting->fetchrow_array())[0])[0]; print "+++ Got prefix of [$prefix]\n"; while(my $file = <$prefix/*.mpg>) { my ($chanid, $starttime) = $file =~ m!/(\d+)_(\d+)\.\w+!; $prog->execute($chanid, $starttime); my @data = $prog->fetchrow_array(); die "Unknown recording $file\n" unless @data; my ($title, $subtitle, $desc) = @data; my ($yyyy, $mm, $dd, $hh, $m, $ss) = $starttime =~ /^(\d{4})(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)$/; die "Misparsed $starttime, got $yyyy,$mm,$dd,$hh,$m,$ss\n" unless defined($yyyy) and defined($mm) and defined($dd) and defined($hh) and defined($m) and defined($ss); print "+++ $file -> $title on $yyyy/$mm/$dd at $hh:$m\n"; my $time = timegm($ss, $m, $hh, $dd, $mm - 1, $yyyy - 1900); my $output = new IO::File(">${chanid}_${starttime}.fxd"); local $::writer = new XML::Writer(OUTPUT => $output); t 'freevo', sub { t 'movie', { title => $title }, sub { t 'cover-img', "$file.png"; t 'video', sub { t 'file', { id => 'f1' }, $file; }; t 'info', sub { t 'plot', $desc; t 'tagline', $subtitle; t 'recording_timestamp', $time; }; }; }; $::writer->end(); $output->close(); } exit; # -- Similar to XML builders in Ruby and Groovy ------------------------------ # sub t() { my ($tag, $attrs, $obj) = @_; ($obj, $attrs) = ($attrs, $obj) unless $obj; $::writer->startTag($tag, %$attrs); if (ref($obj) eq 'CODE') { &$obj; } else { $::writer->characters($obj); } $::writer->endTag($tag); }
Use VLC as Video On Demand (VOD) server for Freevo
This is a description by example, based upon my own config. You need to have vlc installed on the machine you wanna use as VOD server. Installing vlc is quite easy For installing vlc, you could use the vlc wiki.
There are installationpackages for windows and some linux flavors.
http://www.videolan.org/doc/play-howto/en/ch02.html
1. Test Streaming
Once installed vlc you could start streaming some content
For TV cards you could follow this description
http://www.videolan.org/doc/streaming-howto/en/streaming-howto-en.html
For streaming a file, you could use
http://www.videolan.org/doc/streaming-howto/en/ch07.html
To view the stream on a client pc
http://www.videolan.org/doc/streaming-howto/en/ch06.html#id297272
If this works correctly, you could go further.
2. Creating a playlist for VOD
I've put my playlist in /etc/vlm.conf
new bbc2 vod enabled setup bbc2 input pvr:// setup bbc2 option pvr-device=/dev/video1 setup bbc2 option pvr-frequency=273250 new mtv vod enabled setup mtv input pvr:// setup mtv option pvr-device=/dev/video1 setup mtv option pvr-frequency=189250
This is a example for a hauppage ivtv card in linux. It is possible to add files to the VOD experience. Refer to the videolan website and update this if possible.
to make vlc starting the stream
vlc -vvv -I telnet --rtsp-host 192.168.1.1:5554,sdp=sap --vlm-conf /etc/vlm.conf
You need to be patient before vlc has parsed the entire file!!!
Any vlc client (linux, windows) is capable of viewing the VOD stream.
Either use the GUI or the commandline to initiate the VOD
vlc -vvv rtsp://192.168.1.1:5554/mtv
The command above should start a live stream for mtv as defined in the vlm.conf
Creating a daemon to start vlc (linux)
Place a similar file in /etc/init.d called vlc
# # vlc Script to start/stop vlc. # chkconfig: - 61 39 # description: vlc is a media streaming program. # processname: vlc # pidfile: /var/run/vlc.pid# Source function library . /etc/rc.d/init.d/functions# Get network config . /etc/sysconfig/networkprog="vlc" RETVAL=0 VLC_PID="/var/run/vlc.pid"start() stop() restart() reload() case "$1" in start) start ;; stop) stop ;; status) status vlc ;; restart) restart ;; condrestart) [ -f /var/lock/subsys/clamd ] && restart || : ;; reload) reload ;; *) echo $"Usage: $0 " exit 1 esacexit $?
In the file above, I refer to a script in /home/shared/vlc-test containing
/usr/bin/vlc -I telnet --rtsp-host 192.168.1.1:5554 --vlm-conf /etc/vlm.conf 2>&1 > /dev/null
Remember: It could take several minutes to load the playlist.
Modify Freevo to receive a live stream in the TV menu
The credits for this modif goes to Tanja
Check if mplayer is compilled for viewing a received stream
mplayer rtsp://192.168.1.1:5554/mtv
This should work
Modify .../freevo/tv/plugins/mplayer.py after line 133
elif vg.group_type == 'rtsp': self.fc.chanSet(tuner_channel, True, app='mplayer') tvcmd = '' args += ('"rtsp://%s/%s"' % (config.TVSTREAM, tuner_channel),)
Modify /etc/local_conf.py
VIDEO_GROUPS[0].group_type = 'rtsp' TVSTREAM = '192.168.1.1:5554'
The Freebox plugin
The freebox plugin is also capable of starting VOD but creates a extra menu. You need a m3U playlist. My original playlist which works perfectly with vlc couldn't get parsed by the plugin. Therefore a example
#EXTM3U #EXTINF:0,1 - een rtsp://192.168.1.1:5554/een #EXTINF:0,2 - Ketnet rtsp://192.168.1.1:5554/ketnet
Thnx to MaitreTi for providing me a working example of a french freeboxtv m3u file.
Needs some update, since I don't use the freeboxtv for now. It has been specificaly tailored to use with the French FreeboxTV.
Listen to music from a Squeeze server
Use the following fxd file (replacing "hobbes" by the name of your squeeze server):
<?xml version="1.0" ?> <freevo> <audio title="Squeezeserver"> <url>http://hobbes:9000/stream.mp3</url> </audio> </freevo>
Access data from a UPnP server
install djmount.
This allows you to access all data from UPnP servers within your network.
Defines a mount point directory (e.g. /mnt/upnp) and add it to yours AUDIO_ITEMS, VIDEO_ITEMS,... in local_conf.py.
The mount point is activated by command:
djmount /mnt/upnp
In case you want to disable it, type:
fusermount -u /mnt/upnp
A New Background Every Day
This is an extension of the Cartoons with a new skin to use apod (astronomy picture of the day) as the background. The picture will be stretched or squeezed to fit your screen dimensions but usually are acceptable. If not, just wait until tomorrow's picture
First set up to Get Daily Cartoons on your Freevo. Put 'apod' in the getcartoons bash script.
The apod.fxd file was modified from the Panorama file. It looks for an image called apod.jpg in /usr/share/freevo/images
apod.jpg is a symlink to /home/user/pictures/cartoons/Astronomy Picture of the Day/latest
A bash script "cartoonfix" run by cron after "getcartoons" makes a symlink from the newest picture to "latest'. Then restart Freevo to see the new background. "cartoonfix" also adds an image extension ".gif" to each file so that freevo calls the correct plugin.
crontab
m h dom mon dow command 0 4 * * * freevo tv_grab 0 4 * * * /home/tv/getcartoons 30 5 * * * /home/tv/cartoonfix 0 6 * * * /usr/bin/freevo stop 1 6 * * * freevo cache DISPLAY=:0.0 5 6 * * * /usr/bin/freevo start & 0 8 2,16,30 * * /usr/bin/dailystrips-clean 14 0 10 2,16,30 * * /usr/bin/dailystrips-update
getcartoons
!/bin/sh # get my fav cartoons dailystrips --local -stripdir -save -basedir /home/tv/cartoons apod crock hagarthehorrible
cartoonfix
for DIR in "/home/tv/cartoons/Crock" "/home/tv/cartoons/Hagar the Horrible""/home/tv/cartoons/Astronomy Picture of the Day/" ; do for FILE in `ls "$DIR" | egrep -v '\.(gif|jpg|html)$'`; do if [[ $FILE != "latest" ]]; then mv "$DIR/$FILE" "$DIR/$FILE.gif" fi done rm -f "$DIR/latest" ln -s `ls -c "$DIR" | head -n 1` "$DIR/latest" done
apod.fxd
open /usr/share/freevo/skins/main/Panorama.fxd
search for <image label="background" filename="panorama/background.jpg"/> and change the end of the line to read <image label="background" filename="apod.jpg"/> save the file as apod.fxd
make a symbolic link to your downloaded picture ln -s /home/where/did/I/put/it/Astronomy\ Picture\ of\ the\ Day/latest /usr/share/freevo/images/apod.jpg