Project

General

Profile

Setup issues with multiple tuners

Added by Jim Hatfield almost 11 years ago

I have a TBS 6285 which is seen as four tuners. I'm trying to get rid of all the unwanted channels since they clog up the EPG and make it hard to see the channels I want to record. Yet having unticked the Enabled and EPG tickboxes in the Services form, I still see them all in the EPG.

What's the best way of setting up a multiple tuner configuration? Should I set just the first one up, make sure it's exactly what I want, then copy to the others? Also do I need to run "Map DVB Services To Channels" separately for each tuner or just the first?

Also (slightly unrelated) I am recording to an SSD and then trying to move the recordings to a NAS when they are done, so in the Configuration->Digital Video Recorder form I've set Post-processor command to "mv -n %f /storage/videos/unsorted", however the recordings are not being moved. Yet if I ssh in and do itmanually the move happens OK.


Replies (12)

RE: Setup issues with multiple tuners - Added by Jim Hatfield almost 11 years ago

Looks like there is no PATH set when the post-recording command runs, so you need /bin/mv instead of mv. Need to check a couple more recordings to be sure.

RE: Setup issues with multiple tuners - Added by Jim Hatfield almost 11 years ago

Yup, works fine with /bin/mv.

A slight downside is that all completed recordings now appear under the Failed Recordings tab with a status of File Missing. Is there any easy way of updating the database with their new location?

RE: Setup issues with multiple tuners - Added by Prof Yaffle almost 11 years ago

Debate here if it gives any direction: https://tvheadend.org/boards/5/topics/10940?r=10952

Should be able to edit the log files or symlink from old location to new

RE: Setup issues with multiple tuners - Added by Jim Hatfield almost 11 years ago

My sh/awk/sed is very very old but I notice that OpenELEC ships with a Python interpreter so I will have a go at writing a script with copies the file, preserving the directory hierarchy, then fixes up the database and removes the original. Thanks for the pointer.

RE: Setup issues with multiple tuners - Added by Jim Hatfield over 10 years ago

I now have a Python script which

a) looks through all the files in the dvr/log directory looking for ones which contain the recording path, which for me is /var/media/DATA/Recordings.

b) use a regex to pull out the rest of the pathname, and construct the full pathname of the file.

c) construct the full pathname of the destination of the move, which is a NAS mounted on /storage/recordings.

d) ensure that the full path to the destination file exists on the NAS (I have TVHeadend set to create subdirectories per program name).

e) copy source to destination.

f) if OK, overwrite the database file with one which has the path updated to point to the NAS.

g) if OK, unlink the source file.

However, as soon as I overwrite the database file, the recordings vanish from the Completed Recordings tab and appear in Failed Recordings with a reason of File Missing. I checked that the path in the database file matched the true location.

If I kill the TVHeadend process and allow OpenELEC to restart it, then refresh the web page, the recordings now appear in Finished Recordings rather than Failed Recordings.

I had planned to run the Python script via cron at 03:00 so I guess I will invoke it from a shell script then when finished kill TVHeadend with "killall".

RE: Setup issues with multiple tuners - Added by Prof Yaffle over 10 years ago

Well done, that man; any chance you could share the script, Max? It seems to be a common requirement (I think lots of folk either want to archive, or else record locally versus over a network for reliability reasons) so "share and enjoy" could be useful to a wider community.

I've noticed the need to restart the tvheadend daemon as well... I presume the recording logs are cached in some way, and I don't know that there's any API/JSON-type call that would force a re-read. Simply killing the process is easier, although obviously (1) this is no use if it's in use at the time, so recording overnight stuff becomes risky, and (2) it might have implications for re-scanning EPG/re-scanning muxes (the EPG gets saved, and re-scanning might be a good thing, so it's not all bad).

RE: Setup issues with multiple tuners - Added by Jim Hatfield over 10 years ago

Here it is. It will win no prizes for elegance, that's for sure. It's /storage/.config/relocate.py (OpenELEC).

# relocate.py -- relocate recordings to NAS box

# Recordings are initially made to the SSD for safety in the event of network
# problems and/or lack of bandwidth. The path to each recording is stored in a
# (text) database file. This script reads each of the files and scans them for
# a string denoting a recording which has completed but has not yet been moved
# to the NAS. The recording is copied to the NAS and if successful the database
# file is updated and the source file removed.

# The script is invoked by cron at 03:00 when no recordings should be happening

# TODO: some logging would be useful

import os, os.path, re, shutil

# Root path of source recordings
sourcepath = '/var/media/DATA/Recordings/'

# Ditto for destination on NAS box (mounted via CIFS)
destpath   = '/storage/recordings/'

# Location of database files (this for OpenELEC)
dbdir = '/storage/.xbmc/userdata/addon_data/service.multimedia.tvheadend/dvr/log'

def main():
# List the files in the database directory
    dbfiles = os.listdir(dbdir)

# Iterate through the files
    for dbfile in dbfiles:
        dbpath = os.path.join(dbdir, dbfile)

# Read the file into memory
        with open(dbpath) as fd:
            dblines = fd.readlines()

# Scan each line looking for the source path - use indices so we can replace
# Grab the rest of the filename so we can construct full source and dest paths
            tail = ''                               # Pathname tail
            for idx in range(len(dblines)):
                if sourcepath in dblines[idx]:
                    mobj = re.search('"' + sourcepath + r'(.+)"', dblines[idx])
                    if mobj:
                        tail = mobj.group(1)        # Rest of path to file
                        dblines[idx] = dblines[idx].replace(sourcepath, destpath)

# If we have a path tail there must have been a match, so do the move
# Make sure the full path to the destination file exists first
            if tail:
                copyok = True
                copyfrom = os.path.join(sourcepath, tail)
                copyto   = os.path.join(destpath, tail)
                try:
                    os.makedirs(os.path.dirname(copyto))
                except OSError:                     # Already exists
                    pass
                try:
                    shutil.copyfile(copyfrom, copyto)
                except IOError:                     # Couldn't copy, so bail
                    copyok = False

# If the media file copied OK, overwrite the DB file
                if copyok:
                    with open(dbpath, 'w') as fd:
                        fd.writelines(dblines)

# Finally remove the source file
                    os.unlink(copyfrom)

main()

It is invoked by /storage/.config/relocate.sh

#!/bin/sh

# Move completed recordings to the NAS and update the TVHeadend database
/usr/bin/python /storage/.config/relocate.py

# Kill TVHeadend (OpenELEC will restart) so it rereads the database files
killall tvheadend

and this in turn is invoked by cron:

mamba:~ # crontab -l
# At 3am move completed recordings to the NAS and update TVHeadend's database
0 3 * * * /storage/.config/relocate.sh

It's been working fine all week but there is a problem right now in that while TVHeadend can see all the finished recordings just fine, XBMC shows nothing in Live TV->Recordings. Hmm.

RE: Setup issues with multiple tuners - Added by Prof Yaffle over 10 years ago

Is this box always on? What happens if you kill XBMC as well, so it re-loads the PVR addon (and thus has to ask the backend for up-to-date recording information)?

RE: Setup issues with multiple tuners - Added by Jim Hatfield over 10 years ago

I just installed XBMC 3.2 on a Windows PC and it sees the recordings just fine. On the Media PC I can see live TV and the EPG but no recordings. I disable and re-enable the client and they are all back again. Phew!

Wrong forum I know but I like the ability of TVHeadend to create multiple recording configurations with different setups. I have three, different only in that the storage folders are three different folders off the same root, one for my stuff, one for the wife's and one for shared.

Such a pity that when I look at them in XBMC's Recordings tab, that structure is flattened out.

RE: Setup issues with multiple tuners - Added by Prof Yaffle over 10 years ago

Well, if you kill xbmc after restarting tvheadend then that should have the same effect, yes?

Re: profiles... Adam's working on a full re-write of the PVR addon (pvr.tvh to replace pvr.hts). You never know... or maybe now's the time to get into the code and see how it works, and offer a pull request as needed... :)

https://github.com/adamsutton/xbmc-pvr-addons/tree/master/addons/pvr.tvh/addon/resources

RE: Setup issues with multiple tuners - Added by Andrew Dalrymple over 10 years ago

Hi Max,

How do you find the 6285? Have you had any issues? Ive seen lots of complaints about the TSB drivers here, any problems?

(Sorry to hijack your thread, after real world experience before paying 170 quid for one!!!!)

RE: Setup issues with multiple tuners - Added by Jim Hatfield over 10 years ago

It is fine. I have had problems when rebooting between OpenELEC and Windows, when I switch to Windows sometimes all tuners are in a strange state and can't be accessed. Powering down cold then up again fixes this.

I've also seen this twice when using Windows only. But since TVHeadend is Linux only that shouldn't be a problem for you.

Sadly I've had to give up on TVHeadend (or more precisely OpenELEC) since recent versions will not install on my media PC. I can boot into Syslinux but then it hangs. The same stick will boot fine on my old Dell Vostro 200.

So for now, I've decided to go with MediaPortal/ArgusTV on Windows. We shall see. The primary driver for TVHeadend was support for Series Link on UK FreeSat and FreeView, but it didn't work 100% - I would get multiple recordings of The Gadget Show, for example. And I might be able to shoehorn the Series Link CRIDs into ArgusTV by using an XMLTV file generated by a CRID-aware grabber such as EPGCollector.

    (1-12/12)