Difference between revisions of "Play Recordings On Windows From MythWeb"

From MythTV Official Wiki
Jump to: navigation, search
m (Other alternatives: Removed the VFS suggestion - speculation)
("setup" is a noun, not a verb.)
 
(One intermediate revision by the same user not shown)
Line 10: Line 10:
 
* Assumes latest version of Videolan, v0.9.6
 
* Assumes latest version of Videolan, v0.9.6
 
* Yes, you can use Windows Media Player, but it will not play the High-Def MPEG2 streams.
 
* Yes, you can use Windows Media Player, but it will not play the High-Def MPEG2 streams.
* '''Requires Firefox''' (well, it doesn't really, the "File:\\" URLs will open in I.E. but darn if I can be bothered to make it use VLC by default.)
+
* '''Requires Firefox''' (well, it doesn't really, the "file://" URLs will open in I.E. but darn if I can be bothered to make it use VLC by default.)
  
 
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.
 
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.
Line 16: Line 16:
 
==Time to implement==
 
==Time to implement==
  
* 1 to 1-1/2 hour for recordings and ability to setup Samba via command line
+
* 1 to 1-1/2 hour for recordings and ability to set up Samba via command line
  
 
==Install Video Player==
 
==Install Video Player==

Latest revision as of 14:34, 8 February 2012

Introduction

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).

Notes

  • 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
  • Assumes latest version of Videolan, v0.9.6
  • Yes, you can use Windows Media Player, but it will not play the High-Def MPEG2 streams.
  • Requires Firefox (well, it doesn't really, the "file://" URLs will open in I.E. but darn if I can be bothered to make it use VLC by default.)

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 set up Samba via command line

Install Video Player

Videolan and Firefox Addon - Launchy

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 install the Launchy add-on for Firefox. It should automatically add Videolan to your list of possible applications to send the link to. You can check by going under Firefox -> Tools -> Add-ons -> <under Launchy, click on "Options">

  • 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!


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:

\\MyMythBackend\recordings\

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 \\192.168.1.123\\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,"192.168.0.103");
                       # 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 'file:\\\\'.$video_master_url.str_replace('%2F', '/', rawurlencode(basename($show->filename)));
    else
            return 'file:\\\\'.$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, 192.168.0.103 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.
Notes:

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

Reload the recordings page and then right click on Video sm.png and using "Launchy" send the "file:\\Mythbackend\..." URL to Videolan - if it works, then backup your file:

 #cp utils.php utils.php_modified

Upgrading

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:

#!/bin/bash
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.

Troubleshooting

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

TDB

Other alternatives

See Play_Recordings_On_Windows