Redesigning the Hardware for the Virtual TV Streaming Server

This article discusses a hardware design change to the Virtual TV Streaming Server discussed in Creating a Virtual TV Streaming Server.

If you are not familiar with the previous setup. The design revolved around an array of TV tuners connected to a 7-port USB 3.0 hub. In turn, this connected to a USB 3.0 controller which was passed through Discrete Device Assignment (DDA) through to a Windows 10 Virtual Machine. This run DVBLogic TV Mosaic, the IP TV streaming software.

 

Virtual TV Streaming Server Meltdown

The solution has run extremely well. There have been no crashes from TV Mosaic, the VM or the Hypervisor. Until last week.

The system missed last Saturdays recording schedules and on Sunday afternoon, wouldn’t initiate playback. On inspection of the VM, one of the Tuners was showing as “unknown” on the TV Mosaic console. The others were all fine. Once this phantom tuner was removed from the console, everything started working again.

Initially thinking that it was related to a coincidental BIOS update on the server, it turned out that the tuner was simply dead. I RMA’d it with DVBLogic – who didn’t challenge my diagnostic or offer any resistance – but I did have to ship it Internationally at my own expense.

A week later, I came to use the system again and, once more, it was dead. A trip to the attic later and the was dead. A multimeter confirmed that the power supply had died, and I begun an RMA process with StarTech this morning.

 

Analysis

If the power supply on the StarTech was defective, it could potentially have caused the fault with the TV Butler tuner. Although this is speculative and unprovable. My main suspicion is that the problems were caused by heat. The attic roof space is uninsulated, and the UK is in the summer period. With temperature in the attic space certainly to have ranged into the 40c’s.

Unlike with the physical TV server that this setup replaced – which had fans. This setup doesn’t. PCIe TV Tuners are intrinsically designed to withstand higher thermal variances than USB ones. The StarTech and TV Butler products are quite simply basic consumer devices. It is possible that this factor led to both of their demises.

There was a power outage mid-week last week, and the StarTech itself was not sitting on the server UPS – but it was on a surge protector. It is my belief that this did not contribute to the issue.

 

Hardware Redesign

The brief for the redesign is simple

  1. Remove essential electrical components from the attic
  2. Minimise space use
  3. Minimise electrical consumption (as everything will now be powered through the UPS)
  4. Do not clutter up the backplane of the server with dongles

 

Power

To accommodate #1, #2 and #3 the USB Hub is going to be eliminated from the design. The TV Tuners will now connect directly to the DDA USB controller. In order to do this, the dual port controller will need to be replaced.

After deliberating on whether to get an externally powered or bus powered 4-port controller, I chose a , bus powered card. A risk, given my previous experience here. The DG-PCIE-04B reviewed better than a similarly priced externally powered one. The decider was that it uses a NEC chipset and not a RealTek/SiS (i.e. cheap) chip. Finally, the fact that each of the ports had its own voltage management and fuse circuit is a valuable quality safeguard.

 

Patch Panel TV

To satisfy design brief #4, the USB TV Tuners will need to be mounted away from the server. To achieve this, I am going to mount the Tuners in the patch panel.

Using a set of keystone jacks. A USB lead will run between the USB controller and the Patch panel; simply mounting to the TV Tuners held in the patch panel.
TNP USB 3.0 Keystone Jack Image

The patch panel happens to be near the ceiling, directly above the TV aerial distributor for the house. Using 4m coaxial cable, the aerial feed can route through the existing ceiling cable run and clip neatly into the TV Tuners.

The Amazon order consisted of

  • 1x
  • 1x Pack of 5
  • 4x Rankie USB 3.0 Type A Male to Male Data Cable, 3m (Server – Patch Panel)
  • 3x Ex-Pro White Coax F Plug Type – to – Male M Coax plug Connection Cable Lead – 4m (Aerial distributor – TV Tuners)

 

Installation

The installation was extremely simple.

  1. Replace the existing 2 port USB controller with the 4 port one
  2. Clip the USB 3.0 keystones into the patch panel
  3. Run cables between the USB controller and the front profile (base) of the USB keystones
  4. Passing the USB controller through to Hyper-V
    1. Shutdown the Virtual Streaming TV Server VM
    2. Get the Device Instance Path from the Details tab > Device instance path section in Device Manager e.g.
      PCI\VEN_1912&DEV_0014&SUBSYS_00000000&REV_03\4&1B96500D&0&0010
    3. Use PowerShell to dismount the USB Controller from the Hypervisor and attach it to the VM
$vmName = 'TvServer'
$pnpdevs = Get-PnpDevice -PresentOnly | Where-Object {$_.InstanceId -eq 'PCI\VEN_1912&DEV_0014&SUBSYS_00000000&REV_03\4&1B96500D&0&0010'}
$instanceId = $pnpdev.InstanceId
$locationPath = ($pnpdevs[0] | get-pnpdeviceproperty DEVPKEY_Device_LocationPaths).data[0]
Write-Host "    Instance ID: $instanceId"
Write-Host "    Location Path: $locationpath"

# Disable the Device on the Host Hypervisor
Disable-PnpDevice -InstanceId $instanceId -Confirm:$false

# Wait for the dismount to complete
Start-Sleep -s 15

# Dismount the Device from the Host Hypervisor
Dismount-VmHostAssignableDevice -locationpath $locationPath -Force

# Attach the PCIe Device to the Virtual Machine
Add-VMAssignableDevice -LocationPath $locationpath -VMName $vmName

# Note: You may need to reboot the Hypervisor hosts at this point.
# If the VM's device manager informs you that it can see the controller, but is  unable to initialise
# the controllers USB Root Hub. A reboot should fix it.
  1. Clip the DVBLogic TV Butler TV Tuners into the patch panel USB keystone jacks using the inside (top) port on the keystones
  2. Start the TV Server VM
Photograph of USB Tuners mounted in patch panel
The patch panel now has three USB ports – the left-most TV Butler is missing as the RMA replacement has not yet arrived.

Photograph of USB Tuners mounted in patch panel Photograph of USB Tuners mounted in patch panel

The Virtualised Windows 10 Streaming TV Server came back online and there hasn’t been any instability caused by the bus-powered USB controller. The TV Butler’s are warm to the touch, have plenty of air-flow and the ambient temperature can be monitored via existing sensors in the room.

With any luck, I will not need to revisit this project for quite some time!

Installing Plex Media Server on Windows Server 2016 or Windows Server 2019 Core

System Requirements

  • Windows Server Core
  • Windows Server 2012, Windows Server 2012 R2, Windows Server 2016, Windows Server 2019
  • Plex Media Server

 

The Problem

“Just because you shouldn’t do something, doesn’t mean you can’t”

Plex Server, the sometimes controversial media streaming hub, is a staple of the media diet of many home-brew media centre connoisseurs. I personally keep it installed as a gateway between Smart TV’s and my music/video/photo library as it is a convenient way of getting DLNA support on the network. Where pushed due to lack of Kodi support Plex also gives a consistent alternative front-end user interface.

The problem with Plex Server is that it isn’t quite a “server”. It’s a service, but one that insists on running in the userland (as a tray icon). If you log off from its user account, it shuts down the service and you no longer have a working Plex environment.

 

Why is this a problem?

At home, the only computers that I have running 24/7 are servers and these are exclusively Hypervisors. I want Plex to be always on, but not to be sharing a with VM performing other duties. Neither do I want it be forced to leave a logged-on VM running that does something else and thus increases the attack vector.

To date, my answer has been to run Plex Server in a Windows 10 VM, but this means consuming a £120+ Windows 10 Pro license so that it can effectively molly-coddle a tray icon.

Ah ha! I hear you cry. How is consuming a £900 Windows Server license any better?

It’s not, obviously… unless you’ve got Windows Server Data Centre licenses. If you fall into this category, it literally doesn’t matter how many VMs you install on your hypervisor. The argument is academic as long as your have the horsepower on your server to keep piling on additional VMs.

More commonly however, and perhaps more practically. You may find that you have some old Windows Server 2012, 2012 R2 or 2016 Standard licenses knocking around from recent server decommissions. This may become more common again as your organisation starts migrating to Windows Server 2019.

The advantage of using even a down-version of Windows Server comes in the fact that versions of Windows from 2012 upwards all remain part of the Microsoft Long-term Servicing Branch (LTSB) support model. Consequently, by re-using the licenses your Plex install will receive security patches for many years to come, while remaining lighter than a client edition of Windows and – in the cae of Windows 10 – will save you from the 6-monthly ache of having to Feature Update Windows 10. In other words. Server Core gives you a stable platform to ‘set it and forget it’.

So, for these minority edge cases, an experiment was born to see Plex Media Server could in fact run on Windows Server Core.

 

Why Windows Server Core?

Partly because I’m a stickler for pain and partly because at ~5GB (Windows Server 2019), it represents a considerable disk and resource saving over the ~18GB of Windows 10. My Windows 10 VM Plex Server install, with Windows 10 Pro, Plex and its various database (but no local media assets) weighed in at 33GB (after defragging and compressing). Its RAM utilisation typically sitting between 1.4 GB and 1.8 GB (remember that it’s sitting at a user account lock screen most of the time, but a user is logged on non the less).

This gives us some numbers to define relevant success or failure of the experiment against.

 

How To

The new VM was setup with the following specs:

  • 3 CPU Cores*
  • 1024 MB Startup RAM with dynamic memory between 400 MB and 2048 MB
  • A 127 GB dynamic VHDX
  • Connected to the correct network
  • Set (in my case) to PXE boot and install from my build server
  • Windows Server 2019 Core as the install source

*I find that at 2 cores, Plex rides the CPU at 90% during library updates. With 3 cores, it is usually sub 40% and does make use of the available thread afforded from the extra CPU.

 

Minimising

Firstly, remove any unwanted Windows Features. My build server is configured to enable several features by default, so we’ll strip these off. Fewer features and less services mean a leaner VM footprint. Use Get-WindowsFeature in PowerShell* to view the state of play with yours and remove as appropriate. For example

Remove-WindowsFeature -Name Hyper-V

Remove-WindowsFeature -Name Windows-Defender

* At the comment prompt type “start powershell” and hit enter to launch a PowerShell console.

Simiarly, go through Get-WindowsOptionalFeature -online | ? {$_.State -eq 'Enabled'} to check for more things to disable e.g.

Disable-WindowsOptionalFeature -online -FeatureName <name>

As well as Get-Windowscapability -online | ? {$_.State -eq 'Installed'}

Remove-WindowsCapability -online -Name <name>

… and Get-WindowsPackage -online | ? {$_.PackageState -eq 'Installed'} using

Remove-WindowsPackage -online -PackageName <name>

Note: Do not remove WOW64 from the install as you will require it to run Plex.

 

Preparing

If you aren’t automated, patch it, join it to the domian and make any registry and config changes that you need (such as IP addressing and enabling Remote Desktop).

Decide what account your Plex Server install will run in. Obviously, you’ll be sitting in an administrator account after install, and you don’t want to run Plex in that! I have a user account on the domain that has minimal permissions and access to multimedia shares. You should decide what will work for you.

Set the Windows Firewall so that you can perform remote management. Here are some examples of functions that you may wish to enable (they may differ depending on the Windows Server Edition). We need to enable File and Printer Sharing (SMB) access so that we can copy the Plex installer over to the VM from a management workstation.

enable-netfirewallrule -displaygroup "Core Networking"

enable-netfirewallrule -displaygroup "File and Printer Sharing"

enable-netfirewallrule -displaygroup "Network Discovery"

enable-netfirewallrule -displaygroup "Performance Logs and Alerts"

enable-netfirewallrule -displaygroup "Remote Desktop"

enable-netfirewallrule -displaygroup "Remote Event Log Management"

enable-netfirewallrule -displaygroup "Remote Event Monitor"

enable-netfirewallrule -displaygroup "Remote Scheduled Tasks Management"

enable-netfirewallrule -displaygroup "Remote Service Management"

enable-netfirewallrule -displaygroup "Remote Shutdown"

enable-netfirewallrule -displaygroup "Remote Shut-down"

enable-netfirewallrule -displaygroup "Remote Volume Management"

enable-netfirewallrule -displaygroup "Windows Firewall Remote Management"

enable-netfirewallrule -displaygroup "Windows Remote Management"

enable-netfirewallrule -displaygroup "Windows Management Instrumentation (WMI)"

enable-netfirewallrule -displaygroup "Windows Backup"

Before you can run Plex Server, you will also need to enable Windows Media Foundation services.

Add-WindowsFeature -Name Server-Media-Foundation

Now jump to a Management machine, something with Windows 10 1809 and RSAT installed on it.

On the management machine, open Computer Management from the start button right click or by calling the MSC. Right click on “Computer Management (Local)” at the top of the left-hand pane and connect to the machine by hostname or IP Address. You can now:

  • Manage Task Scheduler
  • View the Event Logs
  • Manage Shared Folders
  • Manage Local Users & Groups

Note: If you are in a workgroup, you need to ensure that the user account and password used to open Computer Management matches the administrator account on the Plex VM. Otherwise you will see ‘Access Denied’. You will also need to have setup WinRM, which is beyond the scope of this article.

 

Auto Log-on

Installing on Windows Server will not change Plex’ behaviour. It will still run as a tray service even though there isn’t a systray to display its icon in. This means that the virtual machine must auto log-on at reboot in order to start Plex Server’s services.

To set auto-logon, from an administrator account add the following registry material.

Note: You can type regedit at the command prompt to gain access to the standard Windows registry editor if you prefer to do it manually.

reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /t REG_SZ /v "DefaultUserName" /d "Plex" /f

reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /t REG_SZ /v "DefaultPassword" /d "your_password_here" /f

reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /t REG_SZ /v "DefaultDomainName" /d "your_domain_here" /f

reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /t REG_SZ /v "AutoAdminLogon" /d "1" /f

To test whether you have successfully setup auto-logon, simply reboot the server VM.

Note: The password is inserted in fully readable plain text in the registry. Keep that in mind when designing the security for this account!

 

Install Plex Media Server

Use the following process to install Plex on the new Windows Server Core VM:

  1. Log onto the VM using your preferred Plex user account. For the rest of this article we will call the username for that account “Plex”. This is to create the user account structures.
  2. Download the latest Plex Server installer file from www.plex.tv.
    Note: For some silly reason at the time of writing, the download link is in the page footer with the copyright. It’s almost as if they don’t want you to download it… but I digress.
  3. In file explorer on the management machine, open a SMB share to the VM either using \\<FQDN>\c$ or \\<ipAddress>\c$. Copy the Plex installer file into \\<host>\c$\Users\Plex
  4. Return to the VM via Remote Desktop or your Hypervisor, and ensure that you are logged on as the Plex user account. You should be a command prompt “C:\Users\Plex>”
    1. If your user account is a member of the local administrators group: Type “Plex” and hit tab, it should auto complete the full file name of the Plex installer and hit return e.g.
      Plex-Media-Server-1.14.0.5470-9d51fdfaa.exe
    2. If the Plex account is a standard user: Type “runas /noprofile /user:domain\adminUsername Plex-Media-Server-1.14.0.5470-9d51fdfaa.exe” and hit return.
  5. Should you receive any errors from the installer, you can access the log file via the management machine at the following path to troubleshoot the problem:
    \\<host>\c$\Users\Plex\AppData\Local\Temp

Once the installer has finished, the Launch button will not doing anything as it is attempting to start the default web browser – and there isn’t a default web browser on Windows Server Core. Simply exit the installer to complete the installation.

 

Post-install

At this point you will have the Plex Server binary files installed, however unlike on a GUI install, Plex will not yet function correctly.

 

Drive Maps

Should you need to set up drive maps for media content you can use group policy or create local account mapped shares to your media files using

net use <driveLetter> \\server\share /persistent:yes

 

Auto-Start

Now that Plex is in installed, it is necessary to start its processes. As Windows Explorer (and the startup folder) does not exist to do this for us, you will have to set it up manually.

The obvious way would have been to use task scheduler.

SchTasks /Create /SC ONLOGON /TN "Plex Server" /TR "C:\Program Files (x86)\Plex\Plex Media Server\Plex Media Server.exe"

However, I was unable to get the event to fire at logon and the service never started.

Equally, I was unable to get an auto-run working from HKCU\Software\Microsoft\Windows\CurrentVersion\Run on a non-administrative account, although your mileage may vary if you are using an administrative account.

In the interest of time, the quickest way to achieve this is to use the following procedure:

  1. Log in as a system administrator
  2. Open Regedit
  3. Navigate to:
    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\AlternateShell\AvailableShells
  4. Right click on the AvailableShells key, click Permissions…
  5. Click Advanced
  6. Change the Owner to the administrators group and cascade the ownership change to sub-objects
  7. Set the Administrators group to have Full Control of ‘This key and subkeys’
  8. OK back to Regedit
  9. Edit the REG_SZ under AvailableShells so that you add cmd.exe /k “C:\Program Files (x86)\Plex\Plex Media Server\Plex Media Server.exe” into the Value data string e.g.
    cmd.exe /c "cd /d "%USERPROFILE%" & start cmd.exe /c "C:\Program Files (x86)\Plex\Plex Media Server\Plex Media Server.exe" & start cmd.exe /k runonce.exe /AlternateShellStartup"
    Note: The last command (each & is the start of a seperate command) to be executed will be the window on top after the boot completes.

Note: You cannot use SC as a mechanism to invoke the auto-start as Plex requires the user account to functionally access remote file shares. If all of your media is stored locally on the Plex Server VM then technically you could use SC and in this case you would not need to auto-logon the VM at all.

If you log-off and log-on again you should get the Plex Media Server.exe process running in taskmanager.

 

Adding the ability to Shutdown the VM

If you want your non-administrative user to shutdown the VM without having to log-off, log onto an administrator account and then perform the shutdown. You need to modify the local security policy (or Group Policy) to grant your low security account this right.

You can either

  1. Export a modified policy as a template from your management machine in Local Security Policy (Security Settings > Local Policies > User Rights Assignment > Shut down the system) and then import it onto the Windows Server Core VM using secedit /configure /cfg <exportFilePath> /db secedit.sdb
  2. Use ntrights.exe from the Windows Server 2003 Resource Kit Tools and issue the command ntrights.exe -U "domain\username" +R SeShutdownPrivilege

Download: Windows Server 2003 Resource Kit Tools

 

Open Plex

To start using Plex as part of a new install. Return to your management machine and open a web browser and navigate to:

http://<ipAddress>:32400/web/

You should be presented with the beginning of the Plex configuration wizard in your browser. Do not not be surprised if Plex knows who you are based upon your IP address if you are an existing user. You should be able to  sign-in and configure Plex as required based on it being a new install.

 

Migrating your Plex Server

If you wish to migrate an existing Plex Server into the VM, use the following procedure to perform the migration:

  1. Ensure that both source and destination Plex Installs are running the same version
  2. Shutdown the Plex Media Server processes on both the source and destination Plex Installs by entering
    net stop PlexUpdateService
    tskill "Plex Media Server"
    tskill "PlexScriptHost"
  3. On the old server, export the entirety of the “HKEY_CURRENT_USER\Software\Plex, Inc.” registry key and import it onto the new server
  4. On the new server, rename “C:\Users\Plex\AppData\Local\Plex Media Server” to “C:\Users\Plex\AppData\Local\Plex Media Server-OLD”
  5. Copy the “C:\Users\Plex\AppData\Local\Plex Media Server” folder from the old server to the new server. This folder will be very large and the copy will be very slow as it contains a large number of files and folders. In my case some 662,915 files and folders totalling around 18 GB.
  6. Ensure that your old Plex install remains offline
  7. Reboot the new Plex VM
  8. Test
  9. Delete “C:\Users\Plex\AppData\Local\Plex Media Server-OLD”

 

The Results

At the beginning of the article, I outlined that the old Windows 10 VM disk was sitting at 33 GB with typical idle RAM use sitting around 1.4 GB.

After defragging and compressing the virtual disk for the Windows Server Core VM, the VHDX file size was 27 GB; a small improvement. RAM use was also better. Typical idle values of around 550 MB matched library updates sub-720 MB and observed highs around 900 MB.

Boot times for the VM are considerably faster compared to Windows 10, not that it is especially important for media consumption. As an early superficial observation, the library load times between a Smart TV and the Plex DLNA enumeration service appear snappier than under the previous install. I leave that as a subjective and not an empirical observation however.

So is it worth it? The answer to this should depend on your comfort level with managing Windows Server Core. If you want to play with Server Core to learn it, or are already familiar with it, then it is worth considering for the RAM saving alone. The promise of a long-term stable platform under LTSB servicing does allow you to “set it and forget it” and, if like me you are fed-up of contending with large 6-monthly full reinstalls of Windows 10 for no intrinsic gain. It really does offer a streamlined way to host Plex.

With that said, you do lose three practical things by using Server Core and not much else

  1. The omnipresent tray icon which lets shortcut into the web GUI or manually initiate library scans (all of which you can do from the web UI).
  2. The ability to open the web UI on the VM itself is lost.
  3. Being able to troubleshoot with a GUI in Windows Explorer is occasionally useful. You must now use an intermediate management machine/VM to do this. For any admin who already manages Server Core, they will already have this environment. They will also be used to viewing the local server console as a weapon of last resort, not first resort as will be the case with the majority of GUI administrators.

Once working on Server Core, Plex is essentially managed exclusively through the web UI. There are only very occasional needs to interact with Windows Installer on the console during version upgrades. If you want your Plex VM to do something other than just Plex, then it probably isn’t worth considering going down this route. Should you think like a server admin however and prefer task isolation, then why do you need a GUI, Game Bar and Candy Crush saga to server multimedia content to your TVs? If you think like a savvy consumer, why do you need the extra licensing overhead?

DVBLink 6.0.0 DVB-T/T2 Freeview HD Crystal Palace Channels Missing after tuning

System Requirements:

  • DVBLogic, DVBLink 6.0.0
  • Be in the London Region tuning against Crystal Palace

The Problem:

After tuning DVBLogic DVBLink against Crystal Palace, you are missing a number of channels from the channel list despite having a strong signal. the missing channels may include:

  • 5STAR + 1
  • BT Showcase HD
  • Forces TV
  • FreeSports
  • More4+1
  • PBS America
  • QVC Beauty HD
  • QVC HD
  • Rocks & Co 1
  • London Live
  • POP Max
  • Sony Movie Channel+1
  • The Vault
  • Tiny Pop
  • True Crime
  • True Movies

More Info

The transponder definitions provided for Crystal Palace within DVBLink are currently out of date. consequently, DVBLink only scans 7 transponders instead of the current 9 on the transmitter.

The Fix

You can add the missing transponder data by following the following steps:

  1. Open the DVBLink TVScource configuration web interface and log-in if applicable
  2. Ensure that the “Advanced mode” check box in the top right corner is selected
  3. Go to Sources > TV Sources
  4. Click the config (spanner) icon next to your tuner/tuner group for Freeview
  5. Select search channels
  6. Under ‘select your TV provider’ choose “DVB-T UK (Crystal Palace)” and click next
    Note: The specific transponder settings below will not work for other transponders, however if you can identify transponders for another transmitter, the process is identical
  7. On the left hand side of the current screen there is a long, vertical black bar. Click on it!
    Black bar
  8. At the bottom click the “Edit transponders” button
  9. Add the two missing transponders to the end of the list:
    Note: This is valid as of January 2018, in the future it is liable to change.8=538000,H,9600
    9=586000,H,9600The entire configuration should look like:
  10. click ‘save’
  11. Click the ‘scan’ button on the right hand side of the screen
  12. TVSource will now add the missing channels (16 in my case) to the system
  13. Press OK and configure the new channels as normal

DVBLink 6.0.0 Recordings Database Repair Utility

System Requirements:

  • DVBLogic, DVBLink 6.0.0
  • Windows Scripting Host

The Problem:

DVBLink is a good product which works across a large number of platforms, and, considering how complex it is, it does a good job of interfacing between DVB-T/DVB-S terrestrial TV transmissions and the on-demand world of modern media consumption.

I’ve always had a few niggles with the system (‘clear data’ in Kodi anyone?), but have always found it good, save for one area. It’s recording database mechanic is at best flimsy and at worst out-right fragile.

The number of database corruptions, anomalies and times I have had to restore the database form backup in essence amount to every 6 months. It can be caused by a service crash, the PC restarting without a clean shutdown (power cut), loss of visibility of the disk where the recordings folder target sits (e.g. USB drive, iSCSI recording storage on a SAN/NAS or any other ejectable media) or as a result of installing a DVBLink update (I had a v5 update that trashed my recordings database about 2 months after I first started using it).

To provide a simple summary of the issues with the SQLlite database implementation:

  1. If the database is lost, that’s it. DVBLink/Kodi etc cannot ‘see’ your recordings, they are lost to the software even though they are still physically on disk and if you know where to look and how to open them, they remain watchable.
  2. Some failure situations can lead the database to have more in it than the file system does. This leads to the Kodi ‘click of nothing’, where clicking an item in the recordings section does just that, nothing (no error, just nothing)…
  3. … DVBLink has an option in the server settings to perform a consistency check. This is supposed to fix the ‘I have a database record but no file issue’… yet in reality, in my experience, this far too complicated and (I would assume) tries to be cleverer than asking “is there a recordings file on disk for this recording entry in the database?”. If you have ever tried to manually reconstruct the database with this option on, you’ll know that DVBLink simply deletes the entry…
  4. … Some failure situations – and the DVBLink provided consistency checking option – can lead the database to not have entries for recordings that do exist in the file system. Referring back to #1, you’ll recall that this means that DVBLink/Kodi etc does not know that they exist and you cannot watch the recordings. Equally there is no way to delete the orphaned files as they are not reported. Consequently your DVBLink system will slowly leak disk space. This is made worse by the fact that the database appears to track deletions, but doesn’t appear to have a (working) mechanism to restore the records again.
  5. There is no way to automatically recover from these situations.
  6. Once in these situations, there is no way to recover lost meta data on recording files that are orphaned in the recordings directory.

When a family member with a large pre-existing recording catalogue went away on 22nd December, returned on the 29th December to find that

  1. The old catalogue was no longer showing in Kodi
  2. No new programme recorded before 27th December was present

There were plenty of tears before bedtime.

Due to a connectivity problem between the DVBLink service and the recorder disk on the 27th, DVBLink had restarted and decided that as it couldn’t find the recordings folder, it would delete the now missing content form the recordings database.

It started recording from the 27th onwards onto the tiny local SSD that the OS is installed onto as a fail back (fair dues here DVBLink, good move), but come the 29th there were only 6 things (new content from the 28th and 29th) in the database. There should have been around 70 recordings.

There was no database backup available later than 12th December (by luck, I had made one on the 12th). There was no automatic database backup later than October.

More Info

I now needed to merge the 12th December backup and the 27th December+ master database back together. This would leave a data gap from 13th-26th December of missing records, so having done this in a SQLLite GUI editor, I started the DVBLink back up and… it promptly deleted 85% of all the material introduced from the 12th December backup.

The mystery of the database reconciliation option strikes again. By checking that all of the filenames in the database, I confirmed that the files were on the disk, including the thumbnails, but it decided to delete the imported old records anyway. Just not all of them for an unknown reason.

I turned off the reconciliation option and repeated the merging process again, and, it worked. The files played back in Kodi. I just cannot enable the database reconciliation feature. Ever.

At this point I turned my attention to the missing 13th-26th period. The file system revealed that this amounted to some 14 recordings. At this point I noticed one slight problem. I was expecting to be recovering around 70 files into the database, yet there were over 180, large, playable .ts files in the recording folder consuming some 360 GB of disk space. These files covered a period starting in April 2015 through to 29th December 2017.

Looking non-exhaustively at very old database backup files, I was able to find several of them, proving that they had at one point existed and had not been deleted by the user, but by the database consistence checked/reconciler. This posed the following chain of problems:

  1. If I import the contents of all of the old database backups that I have, I will be importing a mass of junk data.
  2. If I turn on the automatic (and unreliable) consistency checker to clean that up, I will wind up deleting all of the work thus far and likely only be a couple of steps further forward.
  3. I still have not solved the problem of the completely missing 13th December 2017 – 26th December 2017 database records.

I thus decided to write some code and use programming to help solve the problem. Thus the DVBLink_RecordingsDb Maintenance API was created. The API allows you to view:

  • All files in the file system
  • All records in the database
  • All files in the file system that are not in the database
  • All records in the database for which there is no associated file in the file system

In turn it allows you to:

  • Remove entries in the database where the is no resultant file (using no other logic beyond is the correct .ts file presence e.g. the presence of a valid recording timer entry in the database to test validity is not used).
  • Add entries to the database where there is a file in the file system but no existing database entry. The tool will attempt – i.e. best effort – to populate a new database record with the minimum amount of information necessary to allow DVBLink/Kodi to play the file. This is largely based upon the file name and spoofing channel data.
  • Repair file play length information.
  • Scan for an eliminate any duplicate records found in the database

System Requirements

The computer running the tool must:

  • Windows / Windows Server
  • Have the SQLite ODBC Drivers installed (use x86 or x64 depending on your platform)
    Download: http://www.ch-werner.de/sqliteodbc/
  • Be able to access the dlrecorder.db database file as a file system mount (e.g. a direct drive mount, SMB, NFS etc) – under Windows this is in “C:\Users\Public\Documents\DVBLink\dlrecorder.db” by default.
  • Be able to access the recordings folder (the folder where DVBLink writes .ts recording files) as a system mount – under Windows this is in “C:\Users\Public\Documents\DVBLink\recorded” by default.

Usage

To run the code you must be running Windows and ensure that you install the correct SQLite ODBC driver first

  1. Make a manual backup of your dlrecorder.db file. This is found at “C:\Users\Public\Documents\DVBLink\dlrecorder.db”
    Note: If you do not make a backup of the database file and something goes wrong, you will at best lose meta data and at worst lost recordings. Don’t risk it, make a backup!
  2. Download and fully extract the zip file using the link below
    Note: Do not run the programme directly from the zip file
  3. Edit the config.vbs file in notepad or your preferred text editor
  4. Set the DB_PATH variable to the file system path of the dlrecorded.db file used by your DVBLink install. The default is provided
    CONST DB_PATH = “C:\Users\Public\Documents\DVBLink\dlrecorder.db”
  5. Set the RECORDINGS_PATH variable to the file system path of the recorded folder where DVBLink records .ts files. The default is provided
    CONST RECORDINGS_PATH = “T:\DVBLink\recorded”
  6. Save and close the config.vbs file
  7. Double click on the DVBLink_RecordingsUtility.wsf file to start the utility

Repair Utility Screenshot

Download

You can download the DVDLink Recordings Utility below. The code is © C:Amie. Please do not redistribute this file, please link them to this page.

No warranty is offered of implied for using the code, nor loss of data/recordings from your DVBLink database. Please ensure that you make a backup of the DVBLink database before using the tool.

Taking all necessary precautions, use this tool at your own risk.

The tool has been tested on DVBLink 6.0.0 under Windows 10 1709.

If you found this tool useful, please consider donating towards the running costs of this site.

Download: DVBLink_RecordingsTool-1.0.0.zip (8.37KB)

Issues / Ideas

If you have any issues or ideas on how the tool can be made to be more useful, please get in touch.

A thought for the DVBLink team

If anyone from the DVBLink team sees this, I really like what you do – it is a great product, it just has a weak link at the moment. I appreciate fully that you are using SQLlite for search and interrogation performance reasons. You could however fairly easily eradicate these problems by:

  1. Adding granular control to the database consistency checker so that it isn’t so brutal – have whatever mode it currently exists in as an level 2 option and just set a test for the presence of the file in the file system as the level 1 option.
  2. Write an XML/JSON file into the file system with the same name as the recording .ts file or the .jpg thumbnail file. Keep all of the meta data on the recording in here as well as the database. This allows you to implement file portability. With this in place, the consistency checker can be easily re-written to check whether the .ts file has a meta data file too. If it finds a .ts file that it doesn’t know about that does have a meta data XML/JSON file, simply import the file into the database. The database consistency checker algorithm can do this itself on service start/periodically.

If you do that you have several new features:

  1. Portability of recordings without transcoding.
  2. Recording export/import.
  3. An easy, end-user achievable, self-service recovery path from outdated backups with a process that is simple to write up in a knowledge base article.
  4. Significantly less risk / reliance on the integrity of the database. Plus reassurance for you that there is significantly less likelihood that users like me will feel compelled to poke around in the database in the first place.
  5. Support for removable recording targets – when a disk is missing the database is cleared, when it comes back the recordings appear in the database again.
  6. An easy way to report to the user that there are genuinely orphaned files because there is a .ts file with no meta data.
  7. Users can drop in their own .ts file and write their own meta data XML/JSON file for it in a text editor using your schema (also allowing import from competitor products).
  8. A more robust database and file consistency checker / scavenger.
  9. Preservation of disk space use for the user, something that as I have outlined here, seems to leak over time.