Play Recordings On Windows From MythWeb

From MythTV Official Wiki
Revision as of 23:15, 11 September 2008 by Bvj (Talk | contribs)

Jump to: navigation, search


Below are instructions on how users can browse the recordings via Mythweb on a Windows machine and with one click, have it play in VideoLan (VLC).


  • These instructions will not work through a firewall or over a slow < 5Mbps connection and assumes the computers are on the same LAN.
  • It just uses VLC player to view the recordings, not the VLC server to stream the recordings.
  • These instructions only work on MythTV 0.21 (or greater). If you want instructions that work on 0.20 or lower, then look at the history of this page.
  • These instructions work on Vista as well as XP.
  • Assumes Fedora Core

The instructions consist of three parts, first install and configure the necessary Windows applications, share the recordings directory via Samba, then modify a php file.

Time to implement

  • 1 to 1-1/2 hour for recordings and ability to setup Samba via command line

Install Video Player


First get and install VideoLan on your Windows machine. Videolan is an open source video player that can handle all the MPEG codecs.

Second, you will need to modify your windows registry in order for your favorite browser to understand what to do with "myth:" links. Download the file from here (right click and save as), or place the following code with notepad into a file on your windows box called "myth_shellx_vlc_handler.reg" (filename is arbitrary but has to end in .reg), save the file and run it - "Yes" you want to modify the registry.

Windows Registry Editor Version 5.00

@="URL:MythTV File playback Protocol"
"Source Filter"="{2D788796-26AD-4457-8097-EF0846CF8C3A}"
"URL Protocol"=""



@="\"C:\\Program Files\\VideoLAN\\VLC\\vlc.exe\" \"%1\""
  • Note: Make sure the vlc.exe file is in the directory mentioned on the last line above.
  • Note: The registry file is not recognized by Vista and you have to add the update by opening the registry editor (windows key & "r" and run "regedit"), then import the .reg file under File -> Import.
  • Note: You can use other media players but VLC has much better seek hotkeys, i.e. try the forward/backward buttons on your mouse, CTRL-right arrow or ALT-right arrow!

or Media Player Classic

I was not able to get Media Player Classic to play videos because it does not handle the myth:// URLs which get passed to it. To get around this, I wrote a quick script to modify the URL and open mplayerc.exe. Python is needed to run the script, so install that first.

Second, create the script file,, in the same directory as mplayerc.exe with the following contents:

import os, sys
cmd = os.path.join(os.path.dirname(sys.argv[0]), 'mplayerc.exe')
file = sys.argv[1].replace('myth://', '\\\\')
os.execl(cmd, cmd, file)

An alternative is to use windows native scripting. The following script works on Windows XP, other variants should work, such as Windows NT, or Vista. This should be saved to a file that ends in the ".cmd" extension.

set s2=%1
set s1=%s2:myth:=%
"c:\Program Files\MPlayer\mplayer" %s1%

Finally, the registry command needs to be changed from what is described above to run the script:

@="\"C:\\Python24\\pythonw.exe\" "\"C:\\Program Files\\MPC\\\" \"%1\""

Configuring Linux Samba Shares

On your MythTV backend, we are going to add a Samba share which will allow any Windows machine on the network to see all the recordings in the recordings directory on a read-only basis. First make sure the Samba and Lisa daemons are running and will start automatically on bootup:

# /sbin/chkconfig lisa on
# /sbin/service lisa start
# /sbin/chkconfig smb on
# /sbin/service smb start

Now, you could edit "/etc/exports" file and add a line to it like "/video/recordings/ *(r,async,all_squash)" (and restart samba) but it is easier to use the graphical interface of KDE. From the start menu, go to Control Panel -> Internet & Network -> Samba Configuration. You can then click the "Administrator Mode", enter the Root password, and setup the "Base Settings", i.e. Workgroup, Netbios name (leave as default) and the description. Then click on "File Sharing" above in the sidebar and go into "Administrator Mode" again, and "Add" the directory that contains all the MythTV recordings, for example "/video/recordings". Set the share to "visible" but not "writable" to avoid having recordings deleted. The name of the share is used by windows, you could call it "recordings".

  • Note: To restart samba use "service smb restart"
  • Note: If you can't see anything under the "Samba Configuration" or "File Sharing", check if the processes are running:
# ps -A | grep lisa
# ps -A | grep smb

You should also have set the hostname for the machine at this point by

# hostname MyMythBackend

and replace "MyMythBackend" with whatever you want.

  • Note: One of the benefits of having Samba running is that you can now access MythWeb with the hostname, for example http://MyMythBackend/mythweb but make sure the "nmb" service is running.

Now check if your Windows machine can see the recordings directory because there is little point in continuing if it can't. (Give it a few minutes, finding new shares can be slow as it discovers clients, figures out who is the master, etc.) One way to see the share is to enter the following in the Windows Explorer address bar:


replacing the host and share name with yours. Another way is to click on the Start Menu, click Run, and type that into the run command. ie \\\\recordings\

Modifying Mythweb to View Recordings

The next step is to pass to VLC a URL from Mythweb that it can then use to play the recording off the samba share.

The easiest way is to modify one file and at the prompt, first change to the includes directory, make a backup of the file, then edit it:

# cd /var/www/html/mythweb/includes
# cp utils.php utils.php.mybackup
# nano utils.php

Then in the video_url function on about line 328, make the following modifications by changing the original code:

if (!$ext && $_SESSION['file_url_override']) {
   // Which protocol should we use for downloads?

to this:

if (!$ext) {
    $pos1 = stripos($show->filename,"");
                       # Change this ^^^^^^^^^^^^^ 
    $video_slave_url = "Mypath\\to\\my\\recordings\\on\\my\\slave\\backend";
          # Change this ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 
    $video_master_url = "Mypath\\to\\my\\recordings\\on\\my\\master\\backend";
          # Change this ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 
    if ($pos1 == "")
            return 'myth:\\\\'.$video_master_url.str_replace('%2F', '/', rawurlencode(basename($show->filename)));
            return 'myth:\\\\'.$video_slave_url.str_replace('%2F', '/', rawurlencode(basename($show->filename)));
   // Which protocol should we use for downloads?

Here is how the code works: For each recording, it matches the IP address of your slave machine, in the example above, and then it sets hard coded variables, first the network path to slave backend and then the path to the master. If you look at the HTML of the recordings page, there is a large array at the beginning which this script uses. That array contains the slave and master IP addresses in the .filename attribute.

Depending on if the IP address in the filename matches the back end IP address or not, it modifies the value returned to the calling function.

Of course, change the "video_slave_url" to point to your share you set up in previous steps and make sure to use double slashes.

  • This code modifies the direct download icon/link Video sm.png
  • This code works for both slave and master backends
  • It ignores the file_url_override switch in the database.
  • It only works for one slave back end, although it can be expanded easily.
  • You don't need to change anything in your database because everything is hardcoded.

Reload the recordings page and if it works, then backup your file:

 #cp utils.php utils.php_modified


When the next update overwrites your modified file, diff the files to make sure no major changes have occurred, then copy your custom file back over the new one. I have a little script I run after each upgrade that does everything for me:

echo "---------------------> Now checking the diff of utils.php..."
cd /var/www/html/mythweb/includes
diff utils.php utils.php_modified
read -p "Press any key to continue..."
echo "---------------------> Now copying the old modified utils.php over the new one ..."
cp utils.php_modified utils.php
echo "---------------------> Finished!"

It changes into the right directory, does the diff and then pauses while the user checks to see the only difference is the custom code. If everything is ok, it then copies the old modified over the new utils.php.


There are lots of things that can go wrong and the best way to fix it is to track backwards.

  • Can you see the samba share on your windows machine?
  • Is the directory and file in the place you expect, i.e. \\MyMythbackend\recordings\<etc>
  • Can you open that file over the share manually with VLC?
  • Is the path being generated by MythWeb correctly?

Modifying MythWeb to View Videos


Other alternatives

MythTv Player - MythTv Player is a free and simple Myth client and player for Windows.

Tapeworm - TapeWorm is a "parasitic" Windows front end for MythTV

Samba VFS - VFS allows samba to generate filesystems from database queries etc. A module could be written to provide folder and file based access to Myth within a folder structure. This would also require setup of vlc or mediaplayer as above.

Firefox coupled with an Add-on (ie. Launchy ) allows the video URL to be passed directly to the media player (ie. VLC) allowing any media player that supports network streaming to play the file without Firefox first downloading it.